Forum Moderators: coopster
For example, 'log in' becomes 'log out' and 'register' becomes 'my account'.
You can only see these links when logged in.
However, if you were to leave the page without leaving the browser and come back later, it treats you as if you are not logged in. If you refresh the page, nothing changes.
However, when you click the log in link, my pre-programmed error kicks in and tells me I am already logged in. It's not until this point, the header links change.
Here's my code, should it help:
// HEADER.PHP
if (isset($_SESSION['login']) == 1)
{
log out, home.
}
else
{
log in, register.
}
// LOG_IN.PHP
if (isset($_SESSION['login']) == 1)
{
general error.
}
Any help would be ace,
Cheers,
Tom.
using isset just checks if there's anything in $_SESSION['login'] so you can have $_SESSION['login'] = 0 and isset will still return 1.
If $_SESSION['login'] is always 1 or 0, I would make your if statement look like this:
if ($_SESSION['login'] > 0) {
log out,
} else {
etc.
}
// HEADER.PHP
)if (isset($_SESSION['login'])
{
if ($_SESSION['login']) == 1) //if user is logged in
{
log out, home.
}
else
if ($_SESSION['login']) == 0)
{
log in, register.
}
}
else
{
log in, register.
}
// LOG_IN.PHP
if isset($_SESSION['login'])
{
if ($_SESSION['login']) == 1)
{
general error.
}
}