Mark Eriksson
Mark Eriksson

Reputation: 1475

Issue with Cookies

I'm building a font size changer and the size of the new font will be saved in a cookie on the user's computer.

My problem is that when the user changes the font size, if they view the site on "www.site.com", it saves a different cookie to what it does on "site.com", if you understand me?

I looked online and it said that if you set the path of the cookie to '/', it makes the cookie globally accessible across the whole domain and following subdomains, so I set the cookie path to '/' and it made no difference.

What do you propose I do?

Upvotes: 0

Views: 43

Answers (1)

Matt Ball
Matt Ball

Reputation: 359776

Setting the cookie Path to / is correct, but you also should set the cookie Domain to .site.com (note the leading .).

http://en.wikipedia.org/wiki/HTTP_cookie#Domain_and_Path

Upvotes: 2

Related Questions