473,396 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Session Timeout Redirect in a php app

So, I've written some code that kills the session on timeout, but it will not redirect to the login screen unless I try to navigate to another page in the app. Any suggestions?

Expand|Select|Wrap|Line Numbers
  1.         if(isset($_SESSION['start']) ) {
  2.         $session_life = time() - $_SESSION['start'];
  3.         if($session_life > $inactive) {
  4.         $_SESSION = array();
  5.         $session_destroy();
  6.         header('Location:login.php');
  7.         $timedout = '1';
  8.  
  9.     }
  10. }
Jul 17 '15 #1
1 2666
Dormilich
8,658 Expert Mod 8TB
1) why not leave session timeout to PHP? it has a GC for timed-out sessions.

2) redirects not working are 99% due to having output before it. enable error reporting and error display to show error messages concerning that problem.
Jul 19 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: HolaGoogle | last post by:
hi all, can you please tell me what i should do to avoid session timeout when displaying my database info in my asp form (DisplayUserDatabase.asp)??? ** actualy it does load and display the...
12
by: Geigho | last post by:
Setting session timeout in web.config file does not seem to have any effect. Any explanation or suggestion will be appreciated.
6
by: Weave | last post by:
I would like to redirect to a logout page after a session has timed out. I have placed a response.redirect "loggedoff.asp" in the Session_OnEnd subroutine in the global.asa, but it does not move...
2
by: francois | last post by:
in my web.config i have the following : <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
3
by: hn | last post by:
I tried to set session timeout =1 minute as seen below in my Web.config but it didn't work. I also tried to set the timeout in IIS as well and still the application doesn't time out after 1 minute....
20
by: Simon Says | last post by:
Hi, I've a login page in which after authenticating it via the Oracle DB, I will stored the user information into the Session. However, when the Session timeout occurs, all of the user...
0
by: mark4asp | last post by:
Is this class to fix my Session Timeout problem OK? The problem is that users are timing out and the timeout then generates an error entry in the event log. I'd rather not have these entries. ...
3
by: Mufasa | last post by:
Folks, I'm having problems with my session timeout. People using my website leave it just sitting there while they do other things. They have logged in ( using Forms Authentication ) and will be...
4
by: goscottie | last post by:
I used submodal as my popup window. With some tweaks, it working great in my app. However, I can't find a way to detect session timeout in the popup window. The app is a form based...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.