[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

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
0
hansam
Asked:
hansam
1 Solution
 
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.
0
 
kevp75Commented:
2 different domains, 2 different cookies  (and yes that include leaving off the www or not)
0
 
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
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now