Save session
Moderator: General Moderators
Save session
Hello all,
I'm new in this forum and I hope you can help me.
I have to save my session when I close the brower. So i use the cookie to save the session_id, but how can I find the variables which I stored in $_SESSION before closing browser.
Thanks in advance.
Regards.
Laurielle
I'm new in this forum and I hope you can help me.
I have to save my session when I close the brower. So i use the cookie to save the session_id, but how can I find the variables which I stored in $_SESSION before closing browser.
Thanks in advance.
Regards.
Laurielle
Say for example for "Always keep me logged on this PC" or "Remember Me"
Then you can access it again if stored in cookie
Code: Select all
if (isset($_POSTї'RememberMe'])) setcookie ("StoreUser",$user,time()+3600*24*365,"","",0);Code: Select all
if(isset($StoreUser))
// Automatic Login- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
... this code works, provided register_globals is on.. which they should notanjanesh wrote:Then you can access it again if stored in cookieCode: Select all
if(isset($StoreUser)) // Automatic Login
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
To explain my problem, i give you an example.
I'm logged, I answer questions for exam, and for make a break during exam, I have to close the browser directly. When I open again my browser and I logged , I have to find the last question before closing browser. So I have to find the last informations which I have stored in $_SESSION. In my database, I save the data when I valid my answer, so it's not sufficient. I need variables in $_SESSION.
I hope it's more clear.
And another pb with this: the exam has to last 90min so I have to manage the time when I make a break.
Regards.
Laurielle
I'm logged, I answer questions for exam, and for make a break during exam, I have to close the browser directly. When I open again my browser and I logged , I have to find the last question before closing browser. So I have to find the last informations which I have stored in $_SESSION. In my database, I save the data when I valid my answer, so it's not sufficient. I need variables in $_SESSION.
I hope it's more clear.
And another pb with this: the exam has to last 90min so I have to manage the time when I make a break.
Regards.
Laurielle
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
This is the best and most foolproof way. Keep it on the server...feyd wrote:You can save the session data in a database, this will give you more access to the data across sessions and things.. If that's what you need, there's a thread on how to set up database sessions in the Useful Posts thread.
Read up on this as feyd initially suggested
I read the code in the Useful Thread and the example in the website php.net about session_set_save_handler(), but I don't understand many things.
Can you explain me please what I have to code in these functions ? (read, write, open, gc) it's not clear at all.
Do I have to create a db for do that?
Thanks in advance.
Can you explain me please what I have to code in these functions ? (read, write, open, gc) it's not clear at all.
Do I have to create a db for do that?
Thanks in advance.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Yes, http://ca.php.net/manual/fr/function.se ... andler.php
I would like to do like in the example of the site (storage in file), but when I call these functions, what i have to write for $sess_save_path and others variables ?
I would like to do like in the example of the site (storage in file), but when I call these functions, what i have to write for $sess_save_path and others variables ?
- smpdawg
- Forum Contributor
- Posts: 292
- Joined: Thu Jan 27, 2005 3:10 pm
- Location: Houston, TX
- Contact:
First visit
1. Keep the session information in the database.
2. Use the session as a caching mechanism for when the user is on the site.
3. Store some identifier in a cookie to help the site identify the user.
When they revisit the site.
4. Get the cookie.
5. Find their information in the database and repopulate the session.
1. Keep the session information in the database.
2. Use the session as a caching mechanism for when the user is on the site.
3. Store some identifier in a cookie to help the site identify the user.
When they revisit the site.
4. Get the cookie.
5. Find their information in the database and repopulate the session.