Welcome Guest, Not a member yet? Register   Sign In
site wide cookie not working
#1

[eluser]dreamynsx[/eluser]
Hello,

I have a site that has multiple subdomains like test1.mydomain.com, test2.mydomain.com

I'm trying set the cookie so its side wide. The cookie is set but for each subdomain separately. Meaning login in from test1.mydomain.com does not keep me login to test2.mydomain.com. My auth / session code is based on freakauth light and all subdomain sites are using same session database.

Code:
setcookie(
    $this->sess_cookie,
    $this->userdata['session_id'],
    $this->sess_length + $this->now,
    $this->object->config->item('cookie_path'),
    $this->object->config->item('cookie_domain'),
    0
);


Quote:/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookie_prefix' = Set a prefix if you need to avoid collisions
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path' = Typically will be a forward slash
|
*/
$config['cookie_prefix'] = "";
$config['cookie_domain'] = '.mydomain.com';
$config['cookie_path'] = "/";
#2

[eluser]tonanbarbarian[/eluser]
I think you have the parameters in the wrong order

The user manual shows the order of the parameters as

Code:
set_cookie($name, $value, $expire, $domain, $path, $prefix);

and you seem to be doing it in this order
Code:
set_cookie($name, $value, $expire, $path, $domain, $prefix);
#3

[eluser]dreamynsx[/eluser]
Actually its not in wrong order...and actually that code is from CI core library.

That setcookie (without '_') is a php function.

http://www.php.net/setcookie


So order is correct.
#4

[eluser]tonanbarbarian[/eluser]
Ok well the other thing I have noticed in the forums in that people have had issues with cookies if the time on the server is not correct.
Basically the issue is that the expirary date ends up being somewhere in the past, so that then the cookie arrives at the browser it immediately expires
I would look at the cookie in the browser (if possible) and see if it is expiring as it arrives




Theme © iAndrew 2016 - Forum software by © MyBB