CodeIgniter Forums

Full Version: Cookies inside/outside Codeigniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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

El Forum

it probably has something to do with the folder structure...

if your CI part is in

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..

El Forum

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!!

El Forum

Curious why you're forced to direct the user outside of your CI install?