Cannot read cookies in my Joomla site, in Firefox in Safari, works in IE

DJ_AM_Juicebox
DJ_AM_Juicebox used Ask the Experts™
on
I have a simple login form on my Joomla site, which I have created using a module for entering custom code. (I've actually tried a few different ones, with the same results.)  On this login form, I have a "remember me" checkbox, so if the user checks it off, I save the username and password in cookies and fill them out next time they visit. This works fine in IE but in Firefox and Safari, the cookies cannot be read. I actually create them successfully in another module and I can see the cookies in Firefox but they're not in $_COOKIE. I've tried using both PHP and Javascript. Either way, it works in IE but not in Firefox. I've also tried the same code outside of Joomla and it worked fine. Is anyone aware of some Joomla settings that would cause this behavior?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
HaVE YOU ENABLED COOKIES ON YOUR BROWSER?

Author

Commented:
Yes, and the cookies are being stored but cannot be read.
I have found the problem...My cookies were being set on the www domain, so when accessing the site without the www prefix, the cookies could not be read. So I just needed to put '.mydomain.com' in my setcookie function (i.e. setcookie('username', $_POST['username'], mktime()+(86400*30), "/", '.mydomain.com');

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial