Welcome Guest, Not a member yet? Register   Sign In
Trouble in JavaScript method to get the CI session
#1

[eluser]hahacc[/eluser]
$session_data = array('admin'=>$this->input->post("username"));
$this->session->set_userdata($session_data);
$username=$this->session->userdata(admin);//get the username

There is not a problem in the above code,but when I wanna to get the value of admin with JavaScript method,problem starts to ache my head:

a=get_cookie('admin');//Why nothing?

Why I get the cookie with native CI method,but nothing with the JS method?
PS:I'm not using a database to store the session data.

Thanks for sharing me with this problem.
#2

[eluser]xwero[/eluser]
admin is not the name of the cookie. If you didn't change it in the config.php file ci_session is the cookie name.
#3

[eluser]hahacc[/eluser]
Thank for replying.

But,as you say,I tried:

getCookie('ci_session');

But nothing I got later,too.

And besides,I can not find the ci_session cookie in C:\Documents and Settings\Administrator\Cookies.

If I set several cookies in a page,how to get each of them?(for there is only one cookie,namely ci_session)

My question is somehow too fool,yes?
But it really troubles me.
#4

[eluser]hahacc[/eluser]
Or can I get it via:

In controller:
$this->load->helper('cookie');

In view:
echo $a=get_cookie('ci_session');




Theme © iAndrew 2016 - Forum software by © MyBB