Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

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.