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.