[英]Codeigniter session not visible in other pages
Hi friends I am using codeingter default session library. 嗨朋友我正在使用codeingter默认会话库。 I have created normal login and facebook login for my web application using this library.
我使用此库为我的Web应用程序创建了正常登录和facebook登录。
Normal login was working properly with this library, when I tried to do the same with fb login , I am able to see the session variables only in the login page. 正常登录与此库正常工作,当我尝试使用fb登录执行相同操作时,我只能在登录页面中看到会话变量。 When I go to different pages of the website session variables are not visible.
当我去网站的不同页面时,会话变量不可见。
FB login:- print_r($this->session->all_userdata()); FB登录: - print_r($ this-> session-> all_userdata()); for login page is giving me the following array
登录页面给我以下数组
Array ( [session_id] => 18d8f5e5f8504289d848a137e6d8587b [ip_address] => *** [user_agent] => Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0 [last_activity] => 1425530911 [user_data] => [user_id] => 2262 [user_email] => **** [logged_in] => 1 [facebook_login] => 1 [admin] => [logout] => https://www.facebook.com/logout.php?next= *****&access_token=CAANoqwioFoQBACkl2krguKonH3nDamlowXcZCxhqhZAMa1ncOgazFdGXmkSB1QjnpZCweDa1MrXcWK1ZAgUUDHh7Xi7OEJSoJKvt8VXpWYeb3qfcz0mYXmzcLJqZCTFh4PheYD84zGq5u7Q1YQLINS1I7t6KU4EwlGxVMsZBKYjgFAt8tZA5CqSYQ168kvC329TqPZBF2ZAS8j6HfVFcHWsvO )
数组([session_id] => 18d8f5e5f8504289d848a137e6d8587b [ip_address] => *** [user_agent] => Mozilla / 5.0(X11; Ubuntu; Linux x86_64; rv:35.0)Gecko / 20100101 Firefox / 35.0 [last_activity] => 1425530911 [user_data ] => [user_id] => 2262 [user_email] => **** [logged_in] => 1 [facebook_login] => 1 [admin] => [logout] => https://www.facebook.com/ logout.php?下一= *****&=的access_token CAANoqwioFoQBACkl2krguKonH3nDamlowXcZCxhqhZAMa1ncOgazFdGXmkSB1QjnpZCweDa1MrXcWK1ZAgUUDHh7Xi7OEJSoJKvt8VXpWYeb3qfcz0mYXmzcLJqZCTFh4PheYD84zGq5u7Q1YQLINS1I7t6KU4EwlGxVMsZBKYjgFAt8tZA5CqSYQ168kvC329TqPZBF2ZAS8j6HfVFcHWsvO)
where as for other pages the array is null 对于其他页面,数组为null
Please help me to resolve this issue. 请帮我解决这个问题。
This is the model which I am using for fb login 这是我用于fb登录的模型
if($query->num_rows()>0)
> {
> foreach($query->result() as $rows)
> {
>
> //add all data to session
> $newdata = array(
> 'user_id' => $rows->id,
> 'user_email' => $rows->email,
> 'logged_in' => TRUE,
> 'facebook_login' => TRUE,
> 'admin'=>False,
> 'logout' => $logout
> );
> }
>
>
> $this->session->set_userdata($newdata);
>
> $message = $this->session->all_userdata();
>
> return true;
> }
If you are using CI 3 all_userdata() is DEPRECATED, you can use userdata() with no parameters. 如果您使用的是CI 3,则all_userdata()是DEPRECATED,您可以使用不带参数的userdata()。
If the problem remain or your not using CI 3, you can use Native Session library, because CI original session library has some problem. 如果问题仍然存在或您未使用CI 3,则可以使用Native Session库,因为CI原始会话库存在一些问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.