[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Close a session in php after 10 minutes

Posted on 2014-08-29
2
Medium Priority
?
301 Views
Last Modified: 2014-08-29
I have a system created in PHP with MSSQL, this system is public and anyone from around the world can see it, one of the things I need is to create a session to control some part of the system but now my problem is that sessions are giving me problems because the user could let the browser open and the session is still valid and the server at some point is hanging because is consuming many resources.

Is there any way to close the session after x period of time? I have been trying with the settings in the php.ini file but that not solve my problem, some other way to force this?

Thanks in advance for the help.
0
Comment
Question by:GeorgeTowers
2 Comments
 
LVL 29

Accepted Solution

by:
becraig earned 2000 total points
ID: 40293727
I had a similar situation before, all I did was restart the session on each page keeping the session variables and then set a session timeout.

e.g:

        $_SESSION['expire'] = $_SESSION['start'] + (1 *600);

So php takes the session start value and adds 600 seconds for a 10 minute timeout.
0
 

Author Closing Comment

by:GeorgeTowers
ID: 40293744
Thanks. I will do that.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month20 days, 7 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question