Jump to content

Recommended Posts

I'm trying to secure mywebsite before launch and I read some stuff about PHP session hijacking.

 

Right now when a user login I just check their password and username against the database and if it checks out I put their first name, and their unique user Id in a session variable. For any pages that require login I just check to see if the user ID session variable is set. Any security risks with this?

Link to comment
https://forums.phpfreaks.com/topic/89482-php-session-hijacking/
Share on other sites

The way you are doing it is a safe way. Only store one variable in your sessions, and anytime anything needs to be checked, use that variable to do a database query.

 

However, if you have an admin section of your site, it would be best to store that as a separate session variable that is only ever stored on the computers of those with admin status. You should also have the admin table in your database stored as a completely separate table. The reason for this is that a person could potentially hack their session variable and find out their user id, then just start trying user IDs at random until they find one that is an admin. If the admin details are stored in a separate table, and a check is done with an entirely different session variable, they will never have the session variable on their computer to be able to hack, and hacking the one that they do have wont produce any results.

Link to comment
https://forums.phpfreaks.com/topic/89482-php-session-hijacking/#findComment-458319
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.