By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,637 Members | 3,219 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,637 IT Pros & Developers. It's quick & easy.

Storing data for future visits

P: n/a
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.

Francisco
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Francisco wrote:
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.


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.)
Jul 17 '05 #2

P: n/a
Margaret MacDonald wrote:
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


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
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.