General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 18th, 2003, 06:50 AM
vlad_k vlad_k is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Croatia
Posts: 13 vlad_k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post User identification through cookies

An alternative to user identification...

Figuring out how to identify a user and to avoid the PHPSESSID longstring in the URL
(if using sessions) or cookie-based session handling (which is flawed), I came out with
the following method. I would like to ask you for comments:

What is happening upon each access to index.php:

1. A cookie, for example "USERCOOKIE", is tested for existence
2. If the cookie exists, the value is read
3. The value consist of UID:LOGCODE pair, obviously separated by ':'
4. UID is numeric ID into user database
5. LOGCODE is an MD5 encrypted code of a randomly generated 16char string
6. The user is searched for, by UID value in his ID field (primary key unique auto_increment)
7. LOGCODE field is extracted from the database and compared to the one from the cookie
8. If UID exists and LOGCODEs are equal, user is identified by his ID
9. If user exists a new cookie is set to his computer and the database is updated (he
gets a new logcode string)

So, when a user logs in, he receives a logcode in his database entry (UPDATE...).
The cookie is set on his computer, expiration time time()+60 sec. The index.php generates
a page that reloads every 55 seconds.

If the user is idle (does nothing) his browser will reload thus registering himself. Otherwise
upon each access to index.php he is being registered over and over again.

When the user logs out, the cookie is deleted (set by the same name but with empty value
and expiration time set to -3600 sec), and the LOGCODE in the database is set to NULL.

Possible pitfalls:

- slowdown of the system because with each click on the page he is being re-identified
(SELECT, UPDATE, SELECT)

Although regeneration of the LOGCODE is possibly not required, this is to avoid the storage
of last LOGCODE on the client's computer in case he does not log off but shuts down the
connection (or otherwise goes away). Each LOGCODE is valid for 60 seconds or less.

Please share your thoughts...

Vlad.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > User identification through cookies


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway