Thomas George
Thomas George

Reputation: 76

Cookie Saves as two different urls

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

Answers (1)

terales
terales

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

Related Questions