Jump to content

Recommended Posts

I have a header that checks the value of 2 cookies, username and password, against the values in an sql table. the password is md5 in both the table and the cookie, but I just dont know if this is good enough. I dont want anyone to be able to steal the cookie information, and then set the cookies on another computer and have access to the account. How can I prevent this? Should I just not set the md5 password in a cookie?

If you want a user's login information stored in a cookie, then there's no way to prevent a malicious user from stealing the cookie file and using it.

 

Storing it in pure-md5 is silly though, as md5 can be brute-forced extremely quickly. You should always salt hashes as well...

 

Ther ewas a topic on here not too long ago about salting and hashing... check back a couple pages :)

what if i did this, stored a salted hash in the table, then in the cookie do md5($storedsaltedhash.$sessionid) , then when i check to make sure the cookie is ok i do the same thing in my header file so id check

 

if($_COOKIE['authenticate'] == md5($storedsaltedhash.$sessionid))

 

this way even if the cookie was stolen they wouldnt pass a check, i wouldnt store the sessionid in a cookie either, or will i have to? Ive never dealt with sessions so im not sure how all the works precisely

 

would this be ok?

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.