Welcome Guest, Not a member yet? Register   Sign In
Go to specific page when sess_expiration
#1

[eluser]Martin Overgaard[/eluser]
I’am a beginner with CI. I would appreciate help with the code or description for this functionality:

When ”sess_expiration” is activated and the users has been logged out, I like to direct the user to a specific page that says something like “Due to security reasons - you have been logged out. Go to the Login page to log in again.” I other words - not direct to the default login page.

Can somebody help? Many thanks in advance.

Martin
#2

[eluser]InsiteFX[/eluser]
Check to see if they are logged out and if so redirect them to the page.
Code:
redirect('where_you_want_go', 'refresh');

InsiteFX
#3

[eluser]Martin Overgaard[/eluser]
Perfect, Thanks!

How do I check to see if they are logged out from "sess_expiration"?

... I'am a beginner.

Thanks again
Martin
#4

[eluser]InsiteFX[/eluser]
This would depend on what you have set the session_expiration time to. By default it is set to 2 hours 7200.
Code:
$config['sess_expiration'] = 7200;  // 2 hours
So after 2 hours the session will be destroyed.

InsiteFX
#5

[eluser]Martin Overgaard[/eluser]
Thanks. Is the following correct understood:

1. When a user logs out normally trough a normal “log out ” button the session is destroyed and the user is directed to the page I have specified for normal log out.

2. When a user is logged out from “sess_expiration” – let’s say when the chosen two hours are gone – CI automatically refreshes the view and do the redirection to the specified page.

If this is the case, where to I put the redirect('where_you_want_go', 'refresh') to be triggered?

You help is very appreciated.

Martin
#6

[eluser]InsiteFX[/eluser]
Put it in your logout method.

Also in your logout method at this when they logout.
Code:
$this->session_userdata = array();  // Clears out the users data.
$this->session_destroy();

InsiteFX
#7

[eluser]Martin Overgaard[/eluser]
Many thanks InsiteFX,

Got it now.

Best regards
Martin
#8

[eluser]InsiteFX[/eluser]
Your Welcome!

If you have any other issues just post here, I check the forums all day and night LOL!

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB