Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Session help
12-12-2012, 05:05 PM #1
- Join Date
- Dec 2012
- Thanked 0 Times in 0 Posts
I'm coding a forum, and I want users to receive a virtual coin for every minute they're online. I got the session up and working. So far there's a forum where users are able to post and reply threads.
About the coin system, my first problem is that I want to avoid users to abuse the system, so I want a 30 minutes timeout for the session.
Secondly, how do I determine how long the session has been active in PHP?
12-12-2012, 10:28 PM #2
- Join Date
- Feb 2011
- Your Monitor
- Thanked 568 Times in 555 Posts
$_SESSION['login_time'] = time();
Then you know how long ago they logged in.
The downside is you still don't really know when they've stopped viewing the site because PHP is reactive. The only thing you could really do is to see if there is more than 30 minutes since their last usage and if there is don't award any coins. If it's less than 30 minutes then award coins but again you're still up against the php automatic termination of sessions problem so I would suggest going for a 5 or 10 minute time insteadI can't really think of anything to write here now...