Page 1 of 1

[SOLVED] session logout trouble

Posted: Thu Jun 17, 2004 4:16 pm
by Tachyon
I have some code that works fine on my local machine running PHP version 4.3.6 but acts funny when I load it on the Web with a host package running PHP version 4.1.2.

It has to do with ending a session and logging out the user. The code:

Code: Select all

<?php
session_start();

if(!isset($_REQUEST['logmeout'])){
    echo "<center>Are you sure you want to logout?</center><br />";
    echo "<center><a href=logout.php?logmeout>Yes</a> | <a href=javascript:history.back()>No</a>";
} else {
    session_destroy();
    if(!session_is_registered('first_name')){
        echo "<center><font color=red><strong>You are now logged out!</strong></font></center><br />";
        echo "<center><strong>Login:</strong></center><br />";
        include 'login_form.html';
    }
}
?>
In both cases, clicking on "Yes" takes me to URL: http://www.foo.com/project/logout.php?logmeout

Now, in PHP version 4.3.6 it triggers the ELSE section and shows that I've logged out. In the online version (PHP version 4.1.2) it just shows the same page again as if nothing happened. Only the URL changes.

Is my code only good in PHP version 4.3.6? Or is something else going wrong?


feyd|use

Code: Select all

tags. heh oops.[/color]

Posted: Thu Jun 17, 2004 7:14 pm
by Buddha443556
Try setting the variable like this: http://www.foo.com/project/logout.php?logmeout=1

There was a bug in earilier versions of PHP that has been fixed. Found a referenece to the bug here: http://bugs.php.net/bug.php?id=20989

You might look through the change log for specifics.

Posted: Thu Jun 17, 2004 8:50 pm
by Tachyon
That fixed it. Thanks!