Jump to content

Destroying a session if user leaves a site?


extrovertive

Recommended Posts

I'm new with sessions.

All I know with sesssions, the lifetime of it is based on the browser.

However, let's say a user logged into my website (session is registered) and then leave my website. Well, the session is still valid. But I want it so that after they leave my site (not closing the browser), the session is destroy. How would I do this?
Link to comment
Share on other sites

there is no guaranteed method to ensure your session data is destroyed the moment a user leaves your site. Some users don't have JS enabled, some browsers don't have that function. It's easiest to just let PHP do the clean up after session.max_lifetime has expired.
Link to comment
Share on other sites

[quote author=extrovertive link=topic=105022.msg419263#msg419263 date=1156137678]
However, let's say a user logged into my website (session is registered) and then leave my website. Well, the session is still valid. But I want it so that after they leave my site (not closing the browser), the session is destroy. How would I do this?
[/quote]

I would REALLY like to know how you managed that as I have the opposite problem. My session kills every 24 minutes and I want the session to be hours long. Could you send me your session code so I can see maybe what I am doing wrong? I think my problem could be with the phpinfo() on my server but am not sure. Boy I wish I knew how you got it to keep a long session! Please let me know if possible your session code!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.