[SOLVED] session logout trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Tachyon
Forum Newbie
Posts: 7
Joined: Wed Aug 13, 2003 5:09 pm
Location: Lakeside, MT

[SOLVED] session logout trouble

Post 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]
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post 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.
Tachyon
Forum Newbie
Posts: 7
Joined: Wed Aug 13, 2003 5:09 pm
Location: Lakeside, MT

Post by Tachyon »

That fixed it. Thanks!
Post Reply