Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Session Doesn't end when browser is closed???

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Session Doesn't end when browser is closed???

Postby flash_harry » Fri Mar 14, 2003 7:03 am

I have these two scripts. The first one activates a session and registers a name variable :

<?php
session_start();

$name = 'test';
session_register('name');
$_SESSION['name'] = $name;
?>


The second reads the session and prints the variable :

<?php
session_start();

$name = $_SESSION['name'];
if(session_is_registered('name')) echo "$name. The session is still registered.<br /><br />";
else echo "The session is NOT registered.<br /><br />";
?>

However, when I close the browser and reopen it and go back to the page with the second script, it can still read the session variable. Should the session not end when I close the browser? And therefore the variable shouldn't be able to be read once the browser is restarted. Thanx.
flash_harry
New php-forum User
New php-forum User
 
Posts: 26
Joined: Thu Jan 16, 2003 6:05 am

Postby Romantik » Fri Mar 14, 2003 9:58 am

session_unset()
session_destroy()
Romantik
New php-forum User
New php-forum User
 
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson

Postby eyewoo » Mon Mar 17, 2003 5:44 am

I haven't had that problem, so I haven't looked into session_unset() or session_destroy()... but as I think about them, it's unclear to me as to when or where they would be used if you just wanted to end a session when a user left the site. How and where would they be placed in the overall code for a huge, multi-page site where there is no way to predict when a user would shut down their browser or leave the site?

Also, another related question... Is there a timeout on a session's length if there is no browser activity... and if so can the timeout be controled remotely if the developer does not have access to the server's configuration?
eyewoo
New php-forum User
New php-forum User
 
Posts: 71
Joined: Sun Mar 09, 2003 10:29 am
Location: Pennsylvania, USA

Postby flash_harry » Tue Mar 18, 2003 4:04 am

Still have this problem, have used session destroy when the person logs out. This doesn't happen if the user just closes the browser though. They actually have to click the log out button. But surely the session should end when u close the browser???
Could it just be the server configuration and if i override the cookie time length to 0 would that close the session when the browser closes?
flash_harry
New php-forum User
New php-forum User
 
Posts: 26
Joined: Thu Jan 16, 2003 6:05 am

Postby Redcircle » Tue Mar 18, 2003 9:43 am

In the config there is an area where you can specify how long you want the cookie to last. Without looking at the docs I can't tell you where.

Try looking at http://www.php.net/session_start it should have it on that page.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby Hadleigh » Tue Mar 18, 2003 12:47 pm

One obvious thought is that if you had more than one browser window open on the same site and closed only one of them, that behavior would manifest itself naturally.

Hope I'm not teaching mother to suck eggs..

Hadleigh.
Hadleigh
New php-forum User
New php-forum User
 
Posts: 32
Joined: Tue Feb 04, 2003 10:32 am
Location: UK


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron