This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Left4Cake's profile picture

Sessions, php, and cc http api?

Started by Left4Cake, 07 October 2012 - 12:58 PM
Left4Cake #1
Posted 07 October 2012 - 02: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.
makerimages #2
Posted 07 October 2012 - 03: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.
hego555 #3
Posted 08 October 2012 - 06:09 AM
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!
makerimages #4
Posted 08 October 2012 - 12:12 PM
BUT never end the session, exept at logout, then you have a session from login to logout and it should work
Pinkishu #5
Posted 08 October 2012 - 12:15 PM
Hm isn't the browser passed a PHP-Session-ID or something?
Left4Cake #6
Posted 09 October 2012 - 02:29 AM
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>

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".