0

I'm facing a problem in my CodeIgniter application. I'm using set_userdata() to put some information in the session from a specific controller method, and when I try to retrieve this information from another controller method using userdata() it returns empty when using Safari. It works ok when I use Chrome or Firefox.

Here is the controller code:

<?php

class Helloworld extends CI_Controller {
 public function display()
 {

  $this->load->helper('url');
  $this->load->library('session');
  $this->session->set_userdata('some_name', 'some_value');
  //echo $this->session->userdata('some_name');exit; //HERE IT WORKS
  redirect("dashboard");

 }

 public function user_dashboard()
 {

  $this->load->library('session');
  echo "redirect and session test - ";
  echo $this->session->userdata('some_name');exit; //HERE IT FAILS


 }

}
?>

Here is a snippet code from routes.php:

$route['dashboard'] = 'helloworld/user_dashboard';

So, when I access this URL http://mydomainhere.com/CI/index.php/helloworld/display It redirects to this one: http://mydomainhere.com/CI/index.php/dashboard

The output in Chrome and Firefox is: "redirect and session test - some_value" The output in Safari is: "redirect and session test - "

The strange thing is that it works on Safari if I try to retrieve the information in the session inside the same controller method where I put the information in the session. It doesn't work if I try to retrieve the information from another controller method, in this case I assign the information to the session inside the "display" method and I try to get it from "user_dashboard" method.

I appreciate any help.

Thank you guys.

Bruno
  • 71
  • 1
  • 10
  • Have a look at this [answer](http://stackoverflow.com/questions/12907962/codeigniter-session-class-not-working-in-chrome) – Praveen Dabral May 12 '15 at 12:44
  • Hi, tiGer, thanks. I tried a couple of things according to the link you sent, but until now I'm not able to make it work. I tried to set sess_encrypt_cookie to FALSE, and I did the same to sess_match_useragent. I also tried to increase sess_expiration. I tried to recreate the ci_sessions table too. I'll try to clear out the previous session, because this is the only thing I didn't do yet(using $this->session->sess_destroy(), unset_userdata and delete_cookie). I use the domain in URL, so it's not that problem related to "localhost" in the URL. – Bruno May 12 '15 at 21:27

0 Answers0