CodeIgniter Forums
Cookies inside/outside Codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Cookies inside/outside Codeigniter (/thread-22177.html)



Cookies inside/outside Codeigniter - El Forum - 08-31-2009

[eluser]graf[/eluser]
Maybe someone can help me out on this one.... I'm forced to make a user browse outside of the codeigniter system. Inside of a controller i'm doing setcookie('test','test value'); Outside of the controller (example.php) i'm doing echo $_COOKIE['test'] but the cookie doesn't appear to be set. Does codeigniter obscure cookie names, why can't i transfer cookie values outside of the codeigniter system?

What would be an even better solution:
The third party application (outside of codeigniter) thats needed has a function called GetUserID(){} where i'm supposed to hook in my code to grab the userid from the cookie. Is there a way to do GetUserId(){ include('codeigniter.. something'); } So i could use the codeigniter session & possibly get the userId this way?

As of now i have the controller setting the cookie and then forwarding the user to the page outside of codeigniter. On the page outside of codeigniter i'm trying to read in the cookie with no luck.

Thanks for your thoughts/comments


Cookies inside/outside Codeigniter - El Forum - 08-31-2009

[eluser]brianw1975[/eluser]
it probably has something to do with the folder structure...

if your CI part is in site.com/ci/controller/method/var

then the cookie path was probably set as ci/ and you are trying to access a cookie with a default path of /

if you use firefox go to Privacy-> show cookies and search for your site and see where the cookie is actually at

just my guess..


Cookies inside/outside Codeigniter - El Forum - 08-31-2009

[eluser]graf[/eluser]
You the man, i was under the assumption not providing a PATH parameter to setcookie meant the cookie was available for the whole domain... but i got skooled. Thanks!!


Cookies inside/outside Codeigniter - El Forum - 08-31-2009

[eluser]Aken[/eluser]
Curious why you're forced to direct the user outside of your CI install?