Welcome Guest, Not a member yet? Register   Sign In
CI Sessions and IE
#1

[eluser]the future darlo manager[/eluser]
Hi guys, wondering if you can shed some light on this and help me solve a problem I am having with sessions in IE.

In Firefox and other browsers when I logout and destroy the session everything works correctly. If the user types in a url that they visited previously whilst logged in it kicks them out as expected.

In IE however something odd happens. The session appears to be destroyed and and the correct page loaded up. However if the user types in a url that they visited previously whilst logged in it shows the page. If they follow any links or click on any button it kicks them out as expected. Anyone got any ideas? I'm stumped and I've tried this on a couple of computers. Some code below....

I call this in my controller
Code:
//Loads the authenticate user functions from MY_Controller
$this->_authenticate_user();

Here is my MY_Controller
Code:
<?php
class MY_Controller extends Controller
{
    function __construct()
    {
        parent::Controller();
    
    }
    
//////////////////////////////////////////////////////////////////

    function _authenticate_user()
    {        
        //Finds out if the user is logged in
        if ($this->session->userdata('user_id') == FALSE) {
            
            //Redirects the user to the login page and exits
            redirect('welcome', 'refresh');    
            exit();
            
        }
        
    }

//////////////////////////////////////////////////////////////////

}
?>

Here is my logout part...
Code:
function logout()
    {
        
        //Destroy the session
        $this->session->sess_destroy();
        
        //Redirects the user to the admin login page and exits
        redirect('cms/login', '');        
        exit();
    
    }
#2

[eluser]the future darlo manager[/eluser]
I should add when the user closes IE down and restarts it they can't see anything and it redirects them to the correct place if they were not logged in.
#3

[eluser]the future darlo manager[/eluser]
I may have come up with a fix, although I've no idea why this was happening. I noticed that when typing the url back into IE that the page would display despite being logged off. Follow the links / submit a form and it kicks the user out as it should. I then decided to refresh the page and the user was correctly directed to the login page as desired. So I gathered it was a caching problem and decided to add this to my layout file...

Code:
<META HTTP-EQUIV="Expires" CONTENT="Tue, 04 Dec 1993 21:29:02 GMT">

It appears to have done the job. IE is behaving correctly like the other browsers.
#4

[eluser]the future darlo manager[/eluser]
Well I just tried on IE8 on Windows 7 and the problem is kind of still there (didn't realise my other computer I was working on last night had IE7). However its slightly less of an issue....

Once you are logged out typing in a visited, secured by session url still revelas the page content. However if you enter it again the redirection kicks in as it should do.

Still very confused about this....
#5

[eluser]n0xie[/eluser]
It is because of IE Client side Caching.

Take a look here
#6

[eluser]the future darlo manager[/eluser]
Well I've found a solution which appeases the very stupid and utterly hopeless IE8. After a lot of reading....

Stick another header section near the foot of your page after the closing body tag.... so you get this.

Code:
</body>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
</head>

</html>

It works correctly now in IE6, IE7 and IE8. It was never an issue with Firefox, Chrome or Opera.

Guess I stick a conditional in there like I do with my style sheets so it doesn't appear for proper browsers. How stupid is this!
#7

[eluser]the future darlo manager[/eluser]
Just an update on this...

My initial problem in my first post was down to a lack of any sort of no cache meta tags in the header of the page. Far enough. Insert them and it solves the problem on IE6 and IE7.

However on IE8 the problem remains. So I inserted the meta tags in the footer as I stated above. All seems to work now. I decided to show my mate the problem and told him to load up IE8. I stripped out the meta tags in the footer before hand so I could demo it. Without the header tags in the footer he said all was well. Logging out and trying to visit a previously visited URL would take him straight to the login page.

I was stumped. I double checked on my computer without the meta tags and was getting the previous problem as explained in previous posts about IE8. (I.e. initally loading up a page despite being logged out.... visit a link / refresh etc and it kicks you out).

The difference between our computers? He was running Vista and I was running Windows 7. It looks like this header issue only effects IE8 running on Windows 7.
#8

[eluser]skattabrain[/eluser]
Don't mean to resurrect an old post, but this might be useful to some poor soul suffering the torments of IE's handling of their application!

News Flash People ... IE sucks ... anyways, I wish we all could jsut have a coke and never use IE again.

Anyways, using IE 8... I had a severe issue and I can tell you ... your fellow employees or clients think you're a dip stick when they are caching like mad and you're trying to tell them over the phone that things are fine ... it's you! ha!

So I remoted in and sure enough, the problem is real severe and IE 8 is the WORST yet! You think MS would get the hint on this. I have forms that when posted, will then redirect to the page they came from... the info would post ... but you could tell the page didn't refresh because there wasn't so much as a blink before it loaded again. It just didn't reload!

Anyways, I've tried all sorts of headers over the years ... found this MS technote - this should be a sticky on every web dev forum there is ... I'm so flaming PISSED. :vampire:

The solution to IE Cache FAIL

Quote:Certain pages, however, are so volatile or sensitive that they require no disk caching.
:lol: - yeah, like every single forum, wordpress or tool site.




Theme © iAndrew 2016 - Forum software by © MyBB