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
https://forums.phpfreaks.com/topic/17037-session-not-ending/#findComment-71922
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
https://forums.phpfreaks.com/topic/17037-session-not-ending/#findComment-71923
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
https://forums.phpfreaks.com/topic/17037-session-not-ending/#findComment-71937
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
https://forums.phpfreaks.com/topic/17037-session-not-ending/#findComment-72332
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.