Jump to content

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?
look at the onUnLoad function for Javascript

and have it just send a logout command to your login.php script, which I'm assuming you have
you're logout function on that script should destroy the session for you, if you have it written that way
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.
[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!
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.