Forums

PHP

This topic is locked

session_destroy not working

Posted 16 Jan 2002 17:49:34
1
has voted
16 Jan 2002 17:49:34 matt harris posted:
I have a logout link which when clicked takes you to a page called "logout.php", at the top of the page I have :

<?php
session_start();
if (!session_is_registered("adminUser") {
session_register("adminUser";
}
?><?php
session_unset();
session_destroy();
?>

but when I click the back button on my browser I can still access the previous page - which has the same code at the top (minus the session_destro and unset calls).



Replies

Replied 16 Jan 2002 22:42:24
16 Jan 2002 22:42:24 Tim Green replied:
Instead of those code blocks, try instead using:-

<?php
session_unregister("adminUser";
?>

This is a known issue on some PHP versions...

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 16 Jan 2002 23:55:45
16 Jan 2002 23:55:45 matt harris replied:
okay -tried that but no go , when I click on the back button I can still get on the page.

Is it something to do with putting an access script on all the pages - I tried using the Phakt 'restrict access to page' behaviour but it just put me in a loop back to the log in page.

This is all the PHP code I have on the main menu page with a link at the bottom of the HTML to the logout page and your suggestion at the top of the logout page:

&lt;?php
session_start();
if (!session_is_registered("adminUser") {
session_register("adminUser";
}
?&gt;&lt;?php
require("./../adodb/adodb.inc.php";
require("./../Connections/php_conn.php";
?&gt;&lt;?php
$rsMenu__MMColParam = "-1";
if (isset($adminUser))
{$rsMenu__MMColParam = $adminUser;}
?&gt;&lt;?php
$rsMenu=$php_conn-&gt;Execute("SELECT * FROM admin_entrance WHERE ADMIN_USER = '" . ($rsMenu__MMColParam) . "'" or DIE($php_conn-&gt;ErrorMsg());
$rsMenu_numRows=0;
$rsMenu__totalRows=$rsMenu-&gt;RecordCount();
?&gt;

BTW Thanks for your help on the sessions - I got them working...but now can't get them to stop !!!!!

Replied 19 Jan 2002 02:24:46
19 Jan 2002 02:24:46 Tim Green replied:
Make sure that you don't have:-
&lt;?php
session_start();
if (!session_is_registered("adminUser") {
session_register("adminUser";
}
?&gt;

before the session_unregister command. Just put the session_unregister code block on the logout page, and it should work. It does for me.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 23 Jan 2002 12:45:39
23 Jan 2002 12:45:39 matt harris replied:
okay - you're right it works fine however it doesn't work on a mac using Internet Explorer 5 for OS X or OS9 !!

I've tested it on Netscape 6 for Mac and it works fine but Opera also fails the test .

How come Internet Explorer on Mac doesn't work - its fine on PC - I'm using session_unregister .

is anyone else aware of this ?

Replied 23 Jan 2002 20:56:47
23 Jan 2002 20:56:47 Tim Green replied:
It must be an issue with cookie persistence. As sessions use cookies to store reference points it sounds likely that these points aren't being cleared.

Though to be perfectly honest I have never come across this problem myself. Offhand I can't think of a solution.

Perhaps a trawl of the PHP Newsgroups might present a solution?

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 24 Jan 2002 11:33:47
24 Jan 2002 11:33:47 matt harris replied:
Okay - after your last message I decided to do a full test on 3 different machines and got the following results , i've posted this message on all the php newsgroups so hopefuly I'll get some answers:


I have developed an admin application for a website and when testing on
different platforms I found a big problem with Macintosh and IE5 in
particular .

I have a session_unregister command on the logout page which when it loads
automatically logs the user out , if you click the back button on the
browser (on a PC) the previous page tells you to log in again - no problem.

On a mac however the session doesn't unregister itself and you can get
straight back into the site no proble.

So far i've tested it and found this scenario :

Macintosh :

IE5 on Mac OS9 - Doesn't unregister
IE5.1 on Mac OS9 - doesn't unregister
IE5.1 on Mac OSX - doesn't unregister
Opera beta on Mac OSX - doesn't unegister
Netscape 6 - Mac OSX - works fine
Netscape 6 - Mac OS9 -works fine
Netscape 4.7 on mac OS9 - Works fine

anyone else had this problem - i've also tried the session_destroy command
as a back up and had the same results....

matt
<i></i>

Reply to this topic