Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-10-2008, 04:17 AM MD5 Password Cookie
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
I was contacted by a concerned member who said to remove the MD5'd password cookie (when logged in)

However, that would not go with my system, so I guess my system is flawed or could be improved?

Should I insert code here?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!


Last edited by Galaxian; 12-10-2008 at 04:39 AM..
Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
 
Register now for full access!
Old 12-10-2008, 03:47 PM Re: MD5 Password Cookie
Experienced Talker

Posts: 41
Name: Jabis Sevon
Location: Tampere, Finland
Trades: 0
I would suggest you to change your system so that you don't cookie the password (and no, don't do this ever again), but the username+public authentication key for that user, (gathered from the last logintime perhaps) which combined with a serverside private key (hidden in your loginscript for example) produce a succesful logon when tested against the database. For this you could use an "active users" table where you have 3 columns
1) user,
2) timestamp, and
3) the loginhash, which you update on every logon

a simple walkthrough on how it would work
1) login -> check for "remember me" -> store a time variable $time = time();
2) update active users table with current time, username and the hash comprised of md5($username.$time.$privatekey)
3) add a session cookie ($_SESSION['auth'] = "yes") so that you don't need to check the db every refresh
4) add an active user cookie ($_COOKIE['active_user'] = $username.$time; )

now for every page requiring logon, you can first test if the session is available, and an active user is set in the cookie, and retrieve the user info;
if the session isn't valid, then read the active_user cookie and match the hash made from the inners + the private key with the active users tables hash columns; now if a match is found, check the fields of that row and make sure the user is the same and timestamp is not too old or invalid, if you smell fish -> force relogin; otherwise you're ok and can get the user info safely... and with no password saved in a cookie

Edit: If this does not make any sense to you - I'm sorry, but I'm very tired atm... I'll check on this topic when I've slept for more than 2 hours in 2 nights
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by jabis; 12-10-2008 at 03:51 PM.. Reason: Quirks
jabis is offline
Reply With Quote
View Public Profile Visit jabis's homepage!
 
Reply     « Reply to MD5 Password Cookie
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09771 seconds with 12 queries