Reputation: 76
On my website, when users sign up or login, my site sometimes saves the cookie to "mywebsiteurl.com" and sometimes saves it to "www.mywebsiteurl.com". In doing this, my code only works half the time. Is there a way I can fix this issue from happening?
Upvotes: 2
Views: 46
Reputation: 3200
Set cookie in your PHP for your root domain and setcookie()
will automatically make it available for all subdomains:
setcookie('cookiename', 'cookievalue', $someTimeToExpire, '/', 'mywebsiteurl.com');
Upvotes: 1