Forum Moderators: coopster

Message Too Old, No Replies

Session lasting beyond browse close

         

spiffman

8:26 am on Apr 24, 2003 (gmt 0)



I just went through the rigors of learning PHP and MySQL pretty intensely and made my own login and news posting scripts for my website. It also searches users for different data and does a few other cool things.

I'm pretty proud of it, and really enjoying this programming.

Just one question. I am tracking the users with sessions, and when the user closes the browser, the session (and thus their login) ends as well. Any way of preventing this? Pointing me in the right direction would be helpful too. I've looked around and google'd the topic, that's how I found this place. :) Thanks!

DrDoc

8:36 am on Apr 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmaster World!

You can set the cookie lifetime using session_set_cookie_params() [php.net]

Also, you might want to consider just normal cookies through set_cookie() [php.net]

DrDoc

8:38 am on Apr 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also, see the Session Handling [php.net] manual page.

grahamstewart

12:21 pm on Apr 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Had this problem myself lately.

You can also set the cookie lifetime in .htaccess using an entry like..


<IfModule mod_php4.c>
php_value session.cookie_lifetime 180
</IfModule>

The trouble I found with this approach is that it causes 'real' cookies to be used (instead of session cookies).

A different approach would be to record the last access time as a session variable. That way you can check it to see if if the session has timed out.