You just discovered the basics of how cookies work.
The domain
www.yourdomain.tld is (technically speaking) just a subdomain of
yourdomain.tld. They are not the same, and technically, the server
could be set up to show different content on the domain
yourdomain.tld and
www.yourdomain.tld (nobody does this though). Most webhosts have set up their servers to allow both alternatives (with or without the leading subdomain "www").
Cookies-wise, sub-domains are different domains, and out-of-the-box, cookies don't work across domains (that's a security feature, remember!). If you want your cookie to work both with and without leading www subdomain, enable sub-domain independent cookies by changing the cookie domain to
.yourdomain.tld (mind the leading dot).
An even better alternative is to be consistent in the use of your URL: don't mix up links that point to
http://yourdomain.tld/ and
http://www.yourdomain.tld/ - they are different animals.
You as the person who is running a site/domain (notice that I'm trying to avoid the term "webmaster") should be aware of the mechanisms that make the internet tick, so you should understand how domains, cookies and authentification work - not only to make your coppermine-driven gallery work as expected (because the technology does not only apply to coppermine), but for the benefit of all cookie-driven apps.
For clarification: there is a cookie-name (just alphanumerals allowed plus underscore, avoid using a dot in cookie names, just because that's how the technology works), a cookie path (that is meant to determine if the cookie is meant to work for sub-folders within your domain) and a cookie hostname. We can't give general advice how to set them up (as your requirements may differ, depending on your webhosting and server setup), but usually the defaults are OK.
OK, back to the use of the www-subdomain: as end users are not aware of how cookies work and therefor might be inconsistent in their use of the leading www subdomain, it is recommended that you force the use of
one genuine domain name. So, if your webserver is running on apache (most servers are) and your webhost allows you to perform this operation, I recommend setting up a .htaccess file within the webroot of your site that has this content:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.tld$ [NC]
RewriteRule ^(.*) http://yourdomain.tld/$1 [R,L]
This will rewrite the URL if someone is trying to access your site with leading www subdomain to the version without it. We have a similar .htaccess rule in place (you're welcome to try - go to
www.coppermine-gallery.net and observe the "miraculous" change of the URL in the browser's address bar). This way, your site can be accessed both with and without the leading www, and your cookies will always work no matter what.
Joachim