Part of the EllisLab Network
   
 
Session Wont Set on IE7
Posted: 12 May 2008 07:50 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  181
Joined  11-08-2007

A session variable wont be set with IE7 if the session cookie name has an underscore in it.

This is a strange bug, at first I was thought to of believed it was a server side issue (clock out of sync). The tech support however did a test and it worked fine for them.

There are mixed results from different people. It’s very hard to get a definite answer.

function login ($email, $password)
    
{
        $result
= $this->_get_hash($this->users_table, $email); // Grab hash, password, and id from database.

        
if ($result) // Result Found
        
{
            $password
= sha1(sha1($this->salt.$result->hash.$password)); // Hash input password

            
if ($password === $result->password) // Passwords match?
            
{
                $this
->ci->session->set_userdata(array('id'=> $result->id));

                return
true;
            
}
        }
        
        
return false;
    
}

Then check login with

function logged_in ()
    
{
        
return $var = ($this->ci->session->userdata('id')) ? true : false;
    
}

It worked locally for me. Then on the remote server it didn’t, but worked for the server tech over there.

I removed the underscore and it worked perfect. Stumped!

 Signature 

Redux Authentication is a great CodeIgniter Authentication library. It’s light, easy to use and has great features. It’s a great choice for your new or existing project due to the power it gives you.
LevelDesign - Teaching You Something Worthwhile / Mathew Davies - Web Designer / Developer

Profile
 
 
Posted: 12 May 2008 08:58 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6487
Joined  03-23-2006

I have to admit I’m lost.  What underscore?  The only session I can see you’ve set has a key of “id”.

Can you recreate with this

<?php

class Test extends Controller {

    
function __construct()
    
{
        parent
::Controller();
        
$this->load->library('session');
    
}

    
function index()
    
{
        $this
->load->helper('url'); // this is just for the anchor() function
        
        
$this->session->set_userdata('some_name', 'some_value');
        
        echo
anchor('test/set_it_and_forget_it', 'go read the session');
    
}
    
    
function set_it_and_forget_it()
    
{
        
echo "your session is: ";
        echo
$this->session->userdata('some_name');    
    
}

}
?>

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design

Profile
 
 
Posted: 13 May 2008 12:23 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1686
Joined  06-10-2007

I have a similar issue with IE7 where I cannot login a second time after a session cookie has expired. The old cookie is still visible in temporary internet files, and I’m wondering if the login code sees the expired session cookie before managing login and then fails to refresh the cookie.

Manually deleting the cookies allows login to work again. But if I don’t actually logout the cookie is not deleted.

I haven’t investigated this as yet, but if I find something I’ll post back.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | Validation Callbacks into Models | View Object PHP5 | Read the User Guide

Profile
 
 
Posted: 13 May 2008 03:27 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
RankRank
Total Posts:  181
Joined  11-08-2007

Derek Allard : $config[’sess_cookie_name’]= ‘ci_session’;

http://leveldesign.info/redux/index.php/test

It’s really odd. It’s worked for some people, then not others

 Signature 

Redux Authentication is a great CodeIgniter Authentication library. It’s light, easy to use and has great features. It’s a great choice for your new or existing project due to the power it gives you.
LevelDesign - Teaching You Something Worthwhile / Mathew Davies - Web Designer / Developer

Profile
 
 
Posted: 13 May 2008 03:37 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1686
Joined  06-10-2007

Your test site in XP/IE7 worked on the first visit, but once I closed the browser and re-opened in a new window the test fails, ie: no session data is saved.

I also notice there are two cookies from the site in temporary internet files:
Cookie:user@leveldesign.info/
Cookie:user@www.leveldesign.info/

This could be an issue.

EDIT:
Deleting the www.leveldesign.info/ cookie fixed the problem, it does not return and all visits in new browser windows work properly.

The other cookie is updated properly.

This problem does not occur in FF

 Signature 

URI Language Identifier | Modular Extensions - HMVC | Validation Callbacks into Models | View Object PHP5 | Read the User Guide

Profile
 
 
Posted: 13 May 2008 05:07 AM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1686
Joined  06-10-2007

Also found this at php.net/setcookie

IE7 will not delete a cookie value if the time is set to the past.  It will hold the value no matter how far in the past you set the “expire” value.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | Validation Callbacks into Models | View Object PHP5 | Read the User Guide

Profile
 
 
Posted: 13 May 2008 05:32 AM   [ Ignore ]   [ # 6 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1053
Joined  01-07-2008

I haven’t laughed this hard in a long time.  Of all the browsers to mess it up, it had to be IE again.

 Signature 

Blog | Twitter | Coffee

Profile
 
 
Posted: 13 May 2008 05:43 AM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1686
Joined  06-10-2007

Just another day in the life of the web developer, inparo. raspberry

 Signature 

URI Language Identifier | Modular Extensions - HMVC | Validation Callbacks into Models | View Object PHP5 | Read the User Guide

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 60678 Total Logged-in Users: 22
Total Topics: 73095 Total Anonymous Users: 4
Total Replies: 394188 Total Guests: 357
Total Posts: 467283    
Members ( View Memberlist )
Newest Members:  ivamolsindbadlabuddhi.caprakash123connexionsMaxim GuisovmorenoeggtartFoliovenenmru