CodeIgniter Forums
not all controllers can red the cookie Why??????????? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: not all controllers can red the cookie Why??????????? (/showthread.php?tid=18241)



not all controllers can red the cookie Why??????????? - El Forum - 04-29-2009

[eluser]ahmedbloger[/eluser]
hi,every one
i have ea strange problem i have done 80% from my application and i am now want way to check if the user is logged or not and if he logged i want to know his id
so i try to use the cookies and the login function found in controller which i called site
know my problem is that the site controller is only which read the thee cookies,how i can make all controllers read it???????
please help me.


not all controllers can red the cookie Why??????????? - El Forum - 04-29-2009

[eluser]Zeeshan Rasool[/eluser]
if you have this function in controller then you can access it only from that controller.Try to put it in any model, then you will be able to get it in all controllers.


not all controllers can red the cookie Why??????????? - El Forum - 04-29-2009

[eluser]Wuushu[/eluser]
I would turn any session/cookie auth-logic into a library and autoload it, that way I can access it from anywhere within my application by doing something like:

if($user_id = $this->auth->is_logged_in()) (returns user_id OR FALSE)
{
}
else
{
}


not all controllers can red the cookie Why??????????? - El Forum - 04-30-2009

[eluser]ahmedbloger[/eluser]
thank every body but i will explain my problem more
now my default controller is 'site' and it have the llogin funcvtion the problem is that if i go to thrpath
localhost/project/ ->the ci cant read the cookies in this domain
now if i go to the address localhost/project/site/
the ci now read the cookies
so i think the problem is at the cookies domain.



not all controllers can red the cookie Why??????????? - El Forum - 04-30-2009

[eluser]Wuushu[/eluser]
Then set the cookie domain to '/'.


not all controllers can red the cookie Why??????????? - El Forum - 04-30-2009

[eluser]ahmedbloger[/eluser]
i will try it then toll you
thank you