Jump to content

Session Security


markvaughn2006

Recommended Posts

Just curious as to how secure this is...

 

<?php session_start();

if(!$_SESSION['islogged'] ){

    header('Location:login_index.php');}?>

<?php

 

Is there an easy way a to prevent a fake session or cookie from being created and sent to the server??

 

Thanks, this board rocks!

Link to comment
https://forums.phpfreaks.com/topic/175443-session-security/
Share on other sites

You need an exit; statement after your header() redirect to prevent the remainder of the "protected" code on the page from being executed when the page is requested. Without an exit; all a hacker needs to do is ignore the header() redirect and he can still use anything on the protected page the same as if he was logged in.

Link to comment
https://forums.phpfreaks.com/topic/175443-session-security/#findComment-924534
Share on other sites

Cookies are stored on the client machine.  Sessions use cookies.  BUT the only data stored in the session cookie is the ID of the session.  The session data is stored on the server.  So, PHP receives a session ID and looks up the data using this ID.  Yes, a client could modify their session cookie to send a phony session ID, but if that ID does not match a session ID on the server, the server will not find any data for the session.  So a session can be "spoofed" but the hacker would need a valid session ID to get anywhere.

Link to comment
https://forums.phpfreaks.com/topic/175443-session-security/#findComment-925049
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.