Click to See Complete Forum and Search --> : Session expires...


gilly914
December 15th, 2007, 03:16 AM
I have created a standard user login form...
When I login , and don't use the site for a while, the session expires.

How do I change the length of the expiration of the sessions I create??

PeejAvery
December 15th, 2007, 09:54 AM
When you have questions, your first stop should be the PHP documentation. Here (http://us3.php.net/session) is the section about session settings. Pay attention to session.gc_maxlifetime.

Also, are you using IDs and storing them in cookies? If not, you need to do so.

gilly914
December 16th, 2007, 01:01 AM
OK,
I agree with you about the PHP documentation, and i must say that there are a lot of trivial questions that i don't post here, and i look up myself,
but on the other hand, you just gave a good example of why i should post here.
Sometimes, like in this example im afraind there's more than meets the surface about the subject so i rather ask here and have someone tip me on on something... I hope you understand me...

So back to my point,
I don't know how to use ID's and how to store them in cookies... How do i do this? can u please post a small example...


Thanks Alot!

PeejAvery
December 16th, 2007, 08:29 AM
As long as we know you are looking first! Thanks for letting us know.

Concerning sessions ids and cookies...If you will be having a lot of users and are worried about session id swapping, you will want to create a database with a table for session ids currently in use. Other than that, this should take care of you.

<?php
if(@$_COOKIE['session_name'] == ""){
$sesid = 'session_name' . mt_rand(0, 9999999);
setcookie("session_name", $sesid);
}
else{$sesid = $_COOKIE['session_name'];}
session_id($sesid);
session_start();
?>