0

It seems like Codeigniter session is not working in ie & safari. Any one else has faced the same problem?

Is there any solution about this?

<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Test extends CI_Controller {

    var $user;

    public function __construct(){
        parent::__construct();
    }

    public function index(){
        $this->session->set_userdata('test', 'denis');
        var_dump($this->session->all_userdata());
    }

    public function test2(){
        var_dump($this->session->all_userdata());

        phpinfo();
    }
}

response for http://mydomain.com/test

array(5) { ["session_id"]=> string(32) "47d3fec20fc0360ae19994bad84294ba" ["ip_address"]=> string(10) "172.16.1.1" ["user_agent"]=> string(68) "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" ["last_activity"]=> string(10) "1392434286" ["test"]=> string(5) "denis" }

response for http://mydomain.com/test/test2

array(4) { ["session_id"]=> string(32) "5c38c5bc9e1fea7990962fad7626dbd5" ["ip_address"]=> string(10) "172.16.1.1" ["user_agent"]=> string(68) "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" ["last_activity"]=> string(10) "1392434287" }

It doesn't store the cookie, the session is empty.

Denis Omeri
  • 610
  • 1
  • 9
  • 21
  • 2
    Don't post pictures of your code, post textual code snippets. – Mark Feb 15 '14 at 09:27
  • http://stackoverflow.com/questions/8850960/codeigniter-ie-not-storing-sessions-correctly – Reena Shirale Feb 15 '14 at 12:49
  • Denis - if you have not renamed the cookie in config/config.php for sure do what Reena suggested -- remove the underscore from the default cookie name (and optionally you can name it anything you want). an underscore in a cookie name is a known bug for older versions of IE . – cartalot Feb 15 '14 at 22:27

3 Answers3

3

$config['sess_cookie_name'] = 'ci_session'; to $config['sess_cookie_name'] = 'cisession';

Reena Shirale
  • 1,992
  • 1
  • 17
  • 15
0

Just Found the problem:

It wasn't codeigniter bug. The problem was on my linux server configuration.

The hwclock was not coresponding with the date time, and this was causing the session problem on ie & safari...

Denis Omeri
  • 610
  • 1
  • 9
  • 21
  • can you tell more or give some info how to check this and how to fix this? For me session is working but on another page for some reason session variable becomes empty, not always. – Dariux Jul 30 '14 at 11:12
-2

Denis

Thanks for your answer.

my code works fine in IE, Firefox, Chrome etc, but not safari.

It looks like safari block the session to work.

Then I found My server's hardware time and system time are not right.

Then:

[root@new55 ~]# ntpdate 0.rhel.pool.ntp.org 
[root@new55 ~]# hwclock -w 

Everything is fine now.

Thanks again.

Neeku
  • 3,646
  • 8
  • 33
  • 43
Neil
  • 1
  • 1