Jump to content

session not ending


omelette

Recommended Posts

Have a logout page which will cancel your session.

E.g

[code=php:0]<?php
session_start();

if(!isset($_REQUEST['logmeout'])){
    session_unset();
    session_destroy();
    if(!session_is_registered('username')){
        echo "<center><font color=red><strong>You are now logged out!</strong></font></center><br />";
        echo "<center><strong>Login:</strong></center><br />";
        include 'index.php';
    }
}
?>[/code]

Hope this helps,

dual_alliance
Link to comment
Share on other sites

logouts work, but you cannot rely on users to logout and you still have the problem of what to do when a browser is closed without logging out.

sessions should be lost when the browser is closed, although they do persist on the server until automatic cleanup gets rid of them.  They can only be reaccessed if there is some memory of the session id, say in a cookie, and specific code to reopen the session.

how are the sessions being started?

try creating a session variable with some value, close your browser, reopen it and see if the stored value is also retained.  
Link to comment
Share on other sites

I am closing all instances of the browser, I am using Internet Explorer.

I created a session variable and when i close and reopen the browser, the value in the variable is retained.

I am starting the sessions on every page with session_start().

Would the session.cookie_lifetime have anything to do with the problem? It is set to 3600 and i think the default is 0.
Link to comment
Share on other sites

thanks, it seems to work now, not sure why it didn't do anything before.

the only problem is that by setting the cookie parameters to 0, whenever the browser is refreshed, the session is lost so the session doesn't work!  i wanted the session to end only when the browser closes, not when it is refreshed.

any ideas?
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.