rakeshgr Posted October 17, 2007 Share Posted October 17, 2007 Hello Everyone, I am building a website using the PHP 5 and MySQL .I have set up all the required database ready and the PHP pages are linked with the database.I am able to traverse through my pages by querying through the database and inserting and retrieving the stored data from MySQL database. Now i am trying to use sessions in my website so that i can limit the users access and implement session timeouts say if the user is not using the web page for 5 minutes then the session is timed out and he is again asked to relogin. I am trying to implement this functionality in my website. Can anybody please help me in this regard.Please let me know how to secure my website by using session without cookies and what variables or function need to be used or is their any class which can be included in all my web pages so that it will be used to achieve the session timeouts for the specified time. Can anybody please send me source code or example script or developed project where sessions are used and session timeouts arre given in order to logout the idle users afetr the specified time which is specified by us at the server side. Thanks in advance and hope to get the feedback at the earliest. thanks and regards, rakesh. Quote Link to comment https://forums.phpfreaks.com/topic/73614-how-to-use-sessions-in-and-give-session-timeouts-say-after-5-minute-user-relogin/ Share on other sites More sharing options...
steve448 Posted October 17, 2007 Share Posted October 17, 2007 You could set a session to record the time they logged in and then check that against the current time when they go to the next page. //set the login time in a session $_SESSION['time_logged_in'] = time(); //check their time has not expired $time_limit = 5 * 60; // 5 minutes $time_limit = $_SESSION['time_logged_in'] + $time_limit; $time_now = time(); if($time_limit > time_now) { echo 'Your session has expired'; } Quote Link to comment https://forums.phpfreaks.com/topic/73614-how-to-use-sessions-in-and-give-session-timeouts-say-after-5-minute-user-relogin/#findComment-371493 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.