+ Reply to Thread
Results 1 to 2 of 2

Thread: Invalidate cookies on login from new location?

  1. #1
    Barn Regular bryceowen is on a distinguished road bryceowen's Avatar
    Join Date
    Sep 2008
    Location
    Jacksonville, FL
    Posts
    93
    Rep Power
    4

    Invalidate cookies on login from new location?

    There's one forum I visit that (annoyingly) only allows you to stay logged in from one location. (If I login from work and check the 'stay logged in' option, it works fine. However, if I login from home that evening, it doesn't 'remember' on my work computer and I have to log in again. It's a vicious cycle.)

    On a discussion forum, this seems a rather ridiculous policy to enforce. On an intranet site (that requires you to login from your workstation), though, I can see the value. My question is: how would one go about setting a cookie on a user's machine that allows them to save their login credentials, but invalidates those credentials when they login from another machine? (Force a logout on the first machine.)

    Nearest I can come to simulate the effect is to save a unique number [md5(date("U"))] in the user database when they log in and store that same number in a cookie on the machine. That way, when they log in from a new workstation, it checks if the cookie exists and creates a new unique number if it doesn't. When they return to their original workstation, the system compares the cookie's unique number against that stored, sees their different and forces the user to log back in.

    The only problem I see with my work-around is that every page access would require a database query to compare the numbers. A small site wouldn't be a big deal, but surely there's a better way.

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    I would cache the database version of the hash for each user and compare the cookie with that. That way the database call only happens once during that session.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread

Similar Threads

  1. Customized Login Page
    By harish in forum SQL Server Reporting Services Help
    Replies: 2
    Last Post: May 29th, 2009, 01:27 AM
  2. Custom Access Login
    By AOG123 in forum Access Database Samples
    Replies: 6
    Last Post: April 7th, 2009, 11:35 AM
  3. VB.NET & Cookies
    By dr_rock in forum .NET Development
    Replies: 6
    Last Post: March 25th, 2009, 03:47 AM
  4. Forum Statistics Location
    By jmurrayhead in forum Community Support, Suggestions & Feedback
    Replies: 18
    Last Post: July 11th, 2008, 09:35 AM
  5. Basic Login Script (using MS Acesss)
    By BLaaaaaaaaaarche in forum ASP Code Samples
    Replies: 0
    Last Post: March 24th, 2008, 05:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO