CodeIgniter Forums
Cookie set to current path, not entire site - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Cookie set to current path, not entire site (/showthread.php?tid=5755)



Cookie set to current path, not entire site - El Forum - 02-02-2008

[eluser]Bryan Zera[/eluser]
I run the following set_cookie call from /auth/login on my site:
Code:
$domain = '.' . preg_replace("/^www\./", "", $_SERVER['HTTP_HOST']);
            
$cookie = array(
    'name'   => $this->cookie_name,
    'value'  => $username . '|' . md5($password),
    'expire' => 60*60*24*30,
    'domain' => $domain,
    'path' => '/'
);
            
set_cookie($cookie);

But when I try to read the code from /admin, it doesn't work. Am I incorrect in remembering that you can set cookies for an entire domain from a path within the domain?