Welcome Guest, Not a member yet? Register   Sign In
Autometic redirect on login page after session expire
#1

Hi,

I want to add a functionality where after login a user it can automatically redirect login page after a certain time.

Please help.
Reply
#2

@rupamhazra - I have a few questions. How is your security configured for your application (i.e. does it check users access for every page)? Do you use session variables?
Reply
#3

(This post was last modified: 11-08-2016, 09:49 PM by rupamhazra.)

@php_rocs

Yes, i have added session variable and checking the session variable on every page to access also i used cookie for implement "remember me" functionality.Now I want to implement automatic logout after a session.
Reply
#4

Hi,

I have added this functionality..

Thanks.
Reply
#5

This should be straight forward. Where you check you're users access to a page you can incorporate a condition that checks to see if a session variable (one that is set during a successful login) is set. If it is not set then the user is automatically redirected to the login page otherwise continue through to the selected page.
Reply
#6

As an example. When a user logs in you may set a session variable for userid. This variable is available throughout the usage of the application. if the user's browser does not interact with the web server for the specified session time (which is 24 minutes by default - 1440 seconds), the next time the user tries to refresh or go to another page they will automatically be directed to the login page (which will force them to login again).
Reply
#7

You can then use the codeigniter redirect function to take you to the login page. Oh, and don't forget to bring in the url helper [$this->load->helper('url');]. Hopefully this helps you.

Here is a documentation link for the codeigniter function redirect. ( http://www.codeigniter.com/user_guide/he...t#redirect )
Reply
#8

Thanks, but already done these functionality.
Reply
#9

(11-09-2016, 09:27 PM)rupamhazra Wrote: Thanks, but already done these functionality.

Did I miss something?  
Are you trying to set a specific time for each login?  
Are you trying to reset the session time for PHP? 
What exactly are you trying to accomplish?
Reply
#10

(11-10-2016, 08:55 AM)php_rocs Wrote:
(11-09-2016, 09:27 PM)rupamhazra Wrote: Thanks, but already done these functionality.

Did I miss something?  
Are you trying to set a specific time for each login?  
Are you trying to reset the session time for PHP? 
What exactly are you trying to accomplish?

 Yes i have done those points which you have advised.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB