Mark Eriksson
Mark Eriksson

Reputation: 1475

Another Cookie Error

I'm making another project and I'm using cookies to store some unimportant login information.

My problem is that if I go to "www.domain.com", the cookie can be accessed, however, if I go to "domain.com", the cookie cannot be accessed.

I'm writing my project in PHP so if anyone has the answer, or a solution to this problem that would be great.

Thanks, Mark.

Upvotes: 1

Views: 37

Answers (1)

deyes
deyes

Reputation: 657

When you set the cookie, set it as .domain.com.

ini_set('session.cookie_domain', '.site-name.com');

or

setcookie ("cookie_name", "", time() + 3600, "/", ".site-name.com", 1);

Upvotes: 2

Related Questions