Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

ASP & cookies

Options
  • 24-06-2003 2:34pm
    #1
    Registered Users Posts: 876 ✭✭✭


    I have a page where people login while their username is saved to a cookie. Now on my main page I'd like to read these cookies and print them to screen. I can get it working if one user(myself) is logged in but how do I get to read username1, username2, username3 etc and print them to the main page???

    eg:

    Users logged in: username1, username2, username3.

    Thanx in advance.


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    I assume your talking something similar to boards.ie where it tells you on the main page who's online?

    I'm not sure how vBulletin does it, but I would assume it has something to do with keeping record on file or DB everytime someone clicks a link. If a user has been active in the last x minutes (probably 5), then his name is included in the list.

    The server doesn't read any cookies apart from the ones on the browser it's currently talking to. Afaik, there is no store of all cookies currently being read by all server threads, or if there is, it can't be globally read. But I could be wrong.

    For a small username system, you would do it like this:
    When someone does anything at all that shows they are active, i.e. logs in, clicks a link etc, you update a field in the DB called last_active_time or something similar.
    Then when you want to get the currently active users, you'd run a query similar to
    "SELECT username FROM users WHERE last_active_time >= (time() - 3000)"
    (time() - 3000) is php, but you get the idea.

    :)


  • Registered Users Posts: 876 ✭✭✭sirpsycho


    thanx for reply but I wanted to kep away from loggin it in a database. I could prolly try and do it with session variables but i wanted to see if it was possible with cookies 1st. I'll keep trying but in the meantime if anyone figures out how to do it with cookies pls let me know.


  • Registered Users Posts: 3,316 ✭✭✭ButcherOfNog


    Em, the cookies are saved on the client browsers PC's, not the server, how do you plan to have a page running on the server read all these different cookies on different client PC's? You are taking the wrong approach methinks.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Save that data within the Application object, as ButcherOfNog has said Cookies/sessions are user specific and designed not to be global in scope to the application.


Advertisement