charlesdavison
12-08-2004, 04:08 PM
I've set up a MySQL database with a registration and logon area. Login is set up using sessions and is, basically, working.
What I want to do is have the user effectively logged in for a long time (so that if they come back in a few weeks/months they are remembered and logged in).
My first question is:
1. Should this be set as a session cookie with the validity set for a long time or should I set a separate cookie?
The reason I ask is because I was wondering if having loads and loads of sessions open affects performance. Using a separate cookie no data would be stored on the server unless the user was actually using the site at the time.
The other question:
2. Some data will be displayed on each page the user sees. I could access the database every page to retrieve that but it isn't that important that the data is up-to-the-minute accurate. So should I instead store the data in a cookie or session variable and have it updated every 2 hours or so? Would this be greatly preferable to accessing the same data on the database every time?
Sorry about the length of this post, but any opinions & explanations why are greatly appreciated.
What I want to do is have the user effectively logged in for a long time (so that if they come back in a few weeks/months they are remembered and logged in).
My first question is:
1. Should this be set as a session cookie with the validity set for a long time or should I set a separate cookie?
The reason I ask is because I was wondering if having loads and loads of sessions open affects performance. Using a separate cookie no data would be stored on the server unless the user was actually using the site at the time.
The other question:
2. Some data will be displayed on each page the user sees. I could access the database every page to retrieve that but it isn't that important that the data is up-to-the-minute accurate. So should I instead store the data in a cookie or session variable and have it updated every 2 hours or so? Would this be greatly preferable to accessing the same data on the database every time?
Sorry about the length of this post, but any opinions & explanations why are greatly appreciated.