View Single Post
Old 12-18-2012, 02:29 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Cookies are already used by default when specifying the session_start.
If the browser is closed you cannot re-invoke the session. After 24 minutes there is a 1% chance that it will purge the old session records.
For this you need to create database managed sessions. You can use the session_set_save_handler and give it an SessionHandlerInterface object (5.4+) or use each function configured to handle each part of the session (which can also be an object but you need to specify the methods individually). Then you simply do nothing in the gc (garbage collection) function/method.
After this, you specify the session_set_cookie_params and give it the number of seconds it will be valid for. That should let it use a persisting cookie.
See here: http://ca3.php.net/manual/en/functio...ve-handler.php
and http://onlamp.com/pub/a/php/2001/05/10/sessions.html for more information. The latter is old, but the principles are the same. They globalize, but you can get around that by using an object (since you likely won't want to use the old mysql library and opt for either the MySQLi (assuming MySQL in use) or PDO) which can be instantiated with a database connection object and stored locally in a variable.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
kevinkhan (12-18-2012)