Forum Moderators: coopster

Message Too Old, No Replies

Want to keep sessions..

         

firemaster

4:13 am on Jul 16, 2003 (gmt 0)

10+ Year Member



I wrote my user script to use sessions.. no cookies, but when the user exists the page they are logged out. I want them to stay logged in when the come back to the page another time so they don't have to constantly log-in. What is the easiest way to do this, cookies? I have never used them so would need info on how-to..
thanks a lot,
-Mike

hakre

8:08 am on Jul 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi firemaster, welcome to webmasterworld [webmasterworld.com].

cookies are indeed needed for this, check the seesion section in the php docs [php.net], there is a detailed description what they do in session and how sessions work in general.

- hakre

Shadi

3:40 pm on Jul 16, 2003 (gmt 0)

10+ Year Member



try using the php.ini variable:

session.cookie_lifetime = "some number"

you can set this value on the fly in your script as shown below.

where some number is equal to the time as in integre of how long you want the session to stay alive for, the default value is 0 (kill when browser is closed)


<?PHP
$session_expire="90000";
ini_set("session.cookie_lifetime",$session_expire);
session_start();

...

?>

vincevincevince

4:13 pm on Jul 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



remember that sessions USE cookies (unless cookie is disabled by browser, in which case the long?PHPSESSID=5a2nb4j2442o4jlk34h4lk2lw5 style string is appended to the url

so you're probably using cookies already - just they are sent via the session so you didn't realise

firemaster

11:51 pm on Jul 16, 2003 (gmt 0)

10+ Year Member



ooh, thanks all that helped, and Shadi I will try that.
-Mike