Jump to content




Sessions, php, and cc http api?


  • You cannot reply to this topic
5 replies to this topic

#1 Left4Cake

  • Members
  • 272 posts
  • LocationEarth

Posted 07 October 2012 - 01:58 PM

I have an issues and that I tried to make a program to log in to my site it will set the $_SESSION variables but it will not remember then on the next http download.

I use
session_start();
header("Cache-control:private");
to start the session on each page.

#2 makerimages

  • Members
  • 236 posts

Posted 07 October 2012 - 02:07 PM

These work together? oh my lord! i was unaware of that,

on the problem side:

Youre not supposed to start a session at every page, only the login one. Youre currently setting the variables in a session and then creating a new session, wich of course doesnt have the variables set, so just remove the session_start() parts form all the pages exept the login one- should work.

#3 hego555

  • Members
  • 89 posts

Posted 08 October 2012 - 05:09 AM

View Postmakerimages, on 07 October 2012 - 02:07 PM, said:

These work together? oh my lord! i was unaware of that,

on the problem side:

Youre not supposed to start a session at every page, only the login one. Youre currently setting the variables in a session and then creating a new session, wich of course doesnt have the variables set, so just remove the session_start() parts form all the pages exept the login one- should work.

???

You dont know much PHP obviously, if you dont start session you dont have access to session variables!

Also session works with the current session... hence if you do one connection then another they will be different sessions!

#4 makerimages

  • Members
  • 236 posts

Posted 08 October 2012 - 11:12 AM

BUT never end the session, exept at logout, then you have a session from login to logout and it should work

#5 Pinkishu

  • Members
  • 484 posts

Posted 08 October 2012 - 11:15 AM

Hm isn't the browser passed a PHP-Session-ID or something?

#6 Left4Cake

  • Members
  • 272 posts
  • LocationEarth

Posted 09 October 2012 - 01:29 AM

View Postmakerimages, on 07 October 2012 - 02:07 PM, said:

These work together? oh my lord! i was unaware of that,

It does. You just have to remember that its the source code you want and not the <html>

View PostPinkishu, on 08 October 2012 - 11:15 AM, said:

Hm isn't the browser passed a PHP-Session-ID or something?

(one search later) That rights.

htmlgoodies.com/beyond/php/article.php/3472581/PHP-Tutorial-Sessions.htm said:

The session_start( ) function generates a random Session Id and stores it in a cookie on the user's computer

Since Computer Crafts http-api is not really a browser and dose not store cookies the session can never pass back PHPSESSID. :-/ I guess I can try to mimic the session processes manually, by storing a text file with an id and then storing the variable on the site. and then use $_GET to send the "session id".





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users