Storing data for future visits

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Francisco

    #1

    Storing data for future visits

    I have this problem:
    I have a database with information about games, and users are able to vote
    for them. Everytime a user votes for a game I store the unique game name
    into a session variable (an array). So if they are in a page were they
    already voted, they won't have the option to do so.
    The idea is that the session cookie lasts "forever", I don't want them
    voting for the same game everytime they get to the site. This isn't soo
    strict, I don't care if some few users don't accept cookies and eventually
    vote 2 times for the same game.
    So what I did is to have a session cookie with a very large expire time and
    I noted that the session variable data is stored in my server
    in /temp/sess_blabla
    my questions are:

    1. how much does this data last?, can I make it last forever with
    session_cache_e xpire()?
    I still don't like this solution, data would be lost if I change the server,
    I would prefer that the client store this info with his session ID so:

    2. I've searched and read that you can store data in a cookie, but coudln't
    find the way to do it. Can I store this variable in the users session
    cookie?, how?

    3. Any better idea?, maybe storing this info in the database?

    Thank you. I hope I was clear.

    Francisco
  • Margaret MacDonald

    #2
    Re: Storing data for future visits

    Francisco wrote:
    [color=blue]
    >I have this problem:
    >I have a database with information about games, and users are able to vote
    >for them. Everytime a user votes for a game I store the unique game name
    >into a session variable (an array). So if they are in a page were they
    >already voted, they won't have the option to do so.
    >The idea is that the session cookie lasts "forever", I don't want them
    >voting for the same game everytime they get to the site. This isn't soo
    >strict, I don't care if some few users don't accept cookies and eventually
    >vote 2 times for the same game.
    >So what I did is to have a session cookie with a very large expire time and
    >I noted that the session variable data is stored in my server
    >in /temp/sess_blabla
    >my questions are:
    >
    >1. how much does this data last?, can I make it last forever with
    >session_cache_ expire()?
    >I still don't like this solution, data would be lost if I change the server,
    >I would prefer that the client store this info with his session ID so:
    >
    >2. I've searched and read that you can store data in a cookie, but coudln't
    >find the way to do it. Can I store this variable in the users session
    >cookie?, how?
    >
    >3. Any better idea?, maybe storing this info in the database?
    >
    >Thank you. I hope I was clear.[/color]

    It seems to me that, if you really want to store information about a
    user and their choices 'forever', the right place to do that is in
    your own database. Storing anything on the client side that you might
    need across sessions is a fragile strategy. The only things you
    should store there are things that add to that user's convenience, but
    that you yourself don't need.

    Margaret
    --
    (To mail me, please change .not.invalid to .net, first.
    Apologies for the inconvenience.)

    Comment

    • Francisco

      #3
      Re: Storing data for future visits

      Margaret MacDonald wrote:[color=blue]
      > It seems to me that, if you really want to store information about a
      > user and their choices 'forever', the right place to do that is in
      > your own database. Storing anything on the client side that you might
      > need across sessions is a fragile strategy. The only things you
      > should store there are things that add to that user's convenience, but
      > that you yourself don't need.
      >
      > Margaret[/color]

      Well, is not that I want to store information forever, just to make sure
      that it last while the session lasts. And for a big number of users this
      will apply with no problems using cookies, that's why I thought in storing
      the info in the cookie, if it's possible. While the session is active, the
      info will be there. There is no user login of any kind, and I don't want
      it, I want a very simple and easy to use site.

      Francisco

      Comment

      Working...