the reason is because if they log in at a www.foo.com
the cookie domain paramter will be
www.foo.com
so the browser will only send that cookie if the url is exactly www.foo.com
same goes for if they log in on
foo.com
the browser would not send the cookie to pages a url named
www.foo.com
why? because they are essentially different domains, and the browser must play it safe
it doesnt know if your server is configured so that www.foo.com is the same as foo.com
for example, this is common
http://duskwalker.freewebhosting.com
http://rehfeld.freewebhosting.com
so the browser plays it safe so that, for example, if the user visited my site after yours, that i wouldnt be able to read the cookies set from your website.
www IS a legitimate subdomain, its just most servers are configured to make it seem like a useless prefix for convienece
you can inform the browser that its safe to send the cookie to the current domain, and all subdomains as well.
before calling session_start, you must call this
ini_set('session.cookie_domain', '.foo.com'); // notice the leading .