That’s because cookies are domain-specific, and
http://www.whatever is not the same as http://whatever. Technically the www. makes it a subdomain of whatever, which will make the difference to the cookie. Cookies can be configured to work for any subdomain of whatever. This will cause the cookie to work on all subdomains, however, which could cause problems if you are actually working with subdomains that you want to keep separate.
You can add a line to your .htaccess file to cause all www.whatever access to be sent to whatever, or vice versa. Or you can just remember to always log in to www.whatever