Forum Moderators: coopster

Message Too Old, No Replies

ending sessions

         

surrealillusions

3:51 pm on Mar 5, 2008 (gmt 0)

10+ Year Member



Is there a way to end a session when the browser is closed? As the session is used across more than 1 page, i cant really kill the session at the end of the page, otherwise it wont be used when the user goes to another page, or revisits that page.

:)

cameraman

5:21 pm on Mar 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to check this:
session.cookie_lifetime [php.net] integer
session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0.

surrealillusions

6:36 pm on Mar 5, 2008 (gmt 0)

10+ Year Member



ok, thanks but how do i put use that in php?

:)

cameraman

8:20 pm on Mar 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check to see if it's already 0 with phpinfo(). If it's not, change it in your php.ini (if you have access to it) or set it with set_cookie_params() [php.net] (which was a link on the url I posted). According to the docs, if you have to do the latter you'll have to do it in every script, before calling session_start().

If it's already 0, you're probably already good to go - have you tried closing your browser & reopening?

surrealillusions

10:03 pm on Mar 5, 2008 (gmt 0)

10+ Year Member



Looks like it is already 0 in the phpinfo.

But will look into setting it to 0 for future referance just in case i have to write session stuff thats going to be displayed on a different server with it set differently

:)