Page 1 of 1

Weird session problem

Posted: Sun Mar 21, 2010 10:09 pm
by etonB
I'm making a small website where an admin has special functions. I've managed to make my login/logout scripts with sessions and able to show the admin's special functions only to him.

The problem is when logging out and back in, it gets really weird. This is how I can come accross the error:

1. Enter my website
2. Log-in as 'admin'
3. Click on Add News (the special functions)
4. At this point, things work perfect, I can add news and go back to main page.
5. Log-out
6. Log-in as 'admin' again
7. Click on Add News
8. At this point, I get logged out and can't add news obviously until I log in again.

This is how I perform log-out

Code: Select all

<p class="textoIngresar">Welcome, <?php echo $_SESSION["loggedUser"];?> ( <a href="index.php?action=logout">Log-out</a> )</p>
This is the actual log out function

Code: Select all

if ( $_GET["action"] == "logout") 
    {
        session_unset();
        session_destroy();
    }
Am I doing the logout wrong? I need to know if that part is ok so I can look for errors elsewhere.

Thanks in advance,
etonB.

Re: Weird session problem

Posted: Mon Mar 22, 2010 9:15 am
by etonB
Bump, really need input on whether or not I'm doing the log-out right.

Re: Weird session problem

Posted: Mon Mar 22, 2010 10:24 am
by Darhazer
Your login code and how you are checking if the admin is logged in?