Originally posted by tuf-web.co.uk
hi, i have a sessions script for admin controls on my website
such as
<?
session_start()
$isAuth = false; //set to false originally
while($row = mysql_fetch_array($result))
{
if($row['username'] == $username) // if true set $isAuth to true, if not it will stay false
{
$isAuth = true;
}
}
if($isAuth)
{
$_SESSION['logged'] = true;
?>
when my admins log in and then do something like post a message, then return to the admin/index.php they have to log in again!
can somebody please help me, and tell me how to stop this
Thanks in advance
Jon [/B]
Hmm... let's see. First off, make sure you're using "session_start()" on every page.
Then, make a function to check if the user is confirmed.
function check_confirmed_user(){
global $username;
if(!session_is_registered($username)){
echo "You Need to Log in";
exit;
}
}
call this function on every page.
When a user logs in, do like you're doing now, except make sure you register the session variable.
session_register('username');