Welcome Guest, Not a member yet? Register   Sign In
Prevent returning back after logout
#1

[eluser]jbtx[/eluser]
ah hi guyz, I need help

I had been working on my project using CI for about 2 weeks and its only now that i discover this problem

after log-in i get redirected from the login page to the content pages
then log-out, the problem is when i press the back button, it would show the content page which is wrong because i already logout!

i want to know how to prevent it! can someone help me?
#2

[eluser]Rick Jolly[/eluser]
You need to instruct browsers to not cache your page by setting some headers:

Code:
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");

http://ellislab.com/forums/viewthread/78061/

http://ellislab.com/forums/viewthread/51313/#249938
#3

[eluser]Rajeswar[/eluser]
it is not solution Sad
#4

[eluser]louis w[/eluser]
I wouldn't really worry about this. Most sites you can access pages if you hit the back button. If you authentication is set up correctly if they tried to do anything on the page after hitting the back button they would be refused because of the fact that they have logged out.
#5

[eluser]elevend[/eluser]
hi guys..
can anyone help me to prevent returning back after login or logout??
i has tried to use this code:

$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");

but it's not work..

thank you . . .
#6

[eluser]InsiteFX[/eluser]
This is part of the browser's and not recommended!

If it is a problem, logout the user, destroy the session and data
then redirect them back to your login view!
#7

[eluser]skunkbad[/eluser]
@elevend, what browser are you using? I've never had this problem, but then my authentication system is probably different than yours.
#8

[eluser]jbtx[/eluser]
@elevend, try putting this code in your controller's constructor. Still you have to properly check that the user is logged out and won't be able to do anything after it.

Code:
$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
$this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
#9

[eluser]elevend[/eluser]
@skunkbad: i'm using firefox 10.0.2,

@jbtx: i has been tried that, and i has been checked that, the user is logged out.
but it's still not worked.
#10

[eluser]jbtx[/eluser]
Can you post your code here? because it's working on my end.




Theme © iAndrew 2016 - Forum software by © MyBB