Session help

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?
Thank you! :slight_smile:

[php]// Get the current Session Timeout Value
$currentTimeoutInSecs = ini_get(’session.gc_maxlifetime’);

Change the Session Timeout Value

// Change the session timeout value to 30 minutes // 86060 = 8 hours
ini_set(’session.gc_maxlifetime’, 30*60);

// php.ini setting required for session timeout.


as for the second question i would make a database and set it to grab the time of that users session start the get a piece of code to grab that and determine what time is left

but, when you check the database, you also need to make sure that session is actually active. They don’t die out as soon as the person exits the page, and also need to put that on a cronjob that runs every minute.

Sponsor our Newsletter | Privacy Policy | Terms of Service