Jump to content
MakeWebGames

session hijacking


JAMESOMIGHTY

Recommended Posts

ok i have this bit of code in my header to stop session hijacking but occasionaly it can make users suddenly log into other users accounts and be able to do stuff!

 

}
if(isset($_SESSION['userAgent']) && sha1($_SERVER['HTTP_USER_AGENT']) != $_SESSION['userAgent'])
{
echo ('[b]An error has occured with your account, please Sign-In again.

   	Click <a href = "/login.php">HERE</a> to go to the sign in page.[/b]');
session_unset();
session_destroy();
$h->endpage();
exit();
}

else
{

$_SESSION['userAgent'] = sha1($_SERVER['HTTP_USER_AGENT']);
}

 

if anyone can see a problem with this pls post the fix!!!

Link to comment
Share on other sites

That's like letting a kid steal a cookie from the cookie jar, then chasing him around the kitchen trying to get it back.

You're doing it wrong.

If you just secure user input, you don't have to worry about people stealing sessions. Make sure (especially) that profile signatures, forum signatures, mail messages, and any type of 'comment' posts have their content secured properly.

It's better to lock up the cookie jar than go chasing around trying to catch the kid.

Link to comment
Share on other sites

That's like letting a kid steal a cookie from the cookie jar, then chasing him around the kitchen trying to get it back.

You're doing it wrong.

If you just secure user input, you don't have to worry about people stealing sessions. Make sure (especially) that profile signatures, forum signatures, mail messages, and any type of 'comment' posts have their content secured properly.

It's better to lock up the cookie jar than go chasing around trying to catch the kid.

Well said sir :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...