ASP Cookies working and not working?

I have the below ASP functions that I use for cookies. If I visit my webiste with www, the cookies stay cross folders, however if I visit my website without the www the cookies get emptied.

When the user fills out the login form the login script is ran in a seperate folder where the user will be sent. However, as stated above if they login from the www they stay logged in otherwise they don't.

Also when the website is pulled up, I have an if statement that checks if the cookie is empty if it is set it equal to 0.

COOKIE FUNCTIONS:
function GetCookie(Cookie)
      GetCookie = request.cookies(cookie)
end function

sub SetCookie(Cookie,Val)
      response.Cookies(Cookie) = Val
end sub
-=-=-=-=-=-=-=-=-=-=-=-
If Statement for when the site is pulled up:

if getcookie("MyCompany_id") = "" then
      setcookie "MyCompany_id",0
end if
LVL 1
hansamAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

WMIFCommented:
sounds like you may need to add some code to your pages to check for the www in the url.  you should be able to search inside the URL server variable for that, and then redirect to the full url if the www doesnt exist.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kevp75Commented:
2 different domains, 2 different cookies  (and yes that include leaving off the www or not)
AbulhallajCommented:
OK , this is TRUE. becuse domain name with WWW and without that is diffrent but in some host server they refer WWW subdomain to ROOT domain. but when you create a cookie that cookie is encrypted with domain name and also will be diffrent if you use WWW in your address or not. This is becuse of Security I don't thing have any problem
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.