Page 1 of 1

Quick Session Question

Posted: Sat Mar 17, 2007 3:59 pm
by seodevhead
Hey guys... I have a page on my site that allows a user to submit a form... but I only want the person to be able to submit the form once every 24 hours. So as a way to enforce this, I am using a session variable.

How it works:
1. User submits form. Session variable is set to time();
2. If user submits form again, the php asks if isset($_SESSION['formSubmitTime']) and if so, then asks if $_SESSION['formSubmitTime'] < time()*60*60*24.

My question:

Is it okay to set a session variable to last 24 hours? I dunno why it just seems like 24 hours is a long time to maintain a session, am I wrong? Thanks for any advice on this matter.

Posted: Sat Mar 17, 2007 4:29 pm
by nickvd
This very forum's session lasts for about 14 days...

Posted: Sat Mar 17, 2007 4:32 pm
by Kieran Huggins
I have a feeling that closing and re-opening your browser may force a new session anyway... but I could be wrong. Have you considered setting a cookie?

Posted: Sat Mar 17, 2007 5:11 pm
by John Cartwright
How come you think your session lasts 24 hours? All you are doing is setting a timestamp, nothing more and nothing less. Reguardless, there is nothing wrong with having a session last more than 24 hours.. often enough I have firefox open on devnet for several days.