Click to See Complete Forum and Search --> : Refrase cookie question


thechasboi
01-23-2007, 08:32 AM
I have two sites so far that will be sharing folders on the server. I am having trouble with cookies that either do not work or expire prematurely. I have attempted several fixes for this problem but to no avail. I am not sure how difficult this may be but would appreciate some incite to whether I am nuts trying this or not. The reason is obvious why I would like the directories to not be duplicated. If I change one file I would have to make sure I change the others in the other directories. I hope this is not the answer but if it is so be it. Thanks for the reply. I am posting the code In how I attempt to separate the sites. Thanks for the help again.

dim siteLoggingIn
siteLoggingIn = lcase(request.servervariables("SERVER_NAME"))

Sub ValidUser()
'This will allow the user to go to the protected pages
'***Remember whatever you put in this section you have to have logout.asp delete it.***
response.cookies("iv")("Name") = rs("FirstName") & " " & rs("LastName")
response.cookies("iv")("cCon") = rs("FirstName") & " " & rs("LastName")
response.cookies("iv")("cCom") = DefaultValue(rs("Company"))
response.cookies("iv")("cE") = DefaultValue(rs("email"))
response.cookies("iv")("cP") = DefaultValue(rs("Phone"))
response.cookies("iv").Expires = DateAdd("m",12,Date)
response.Cookies("iv").domain = "www." & siteLoggingIn
'response.Cookies("iv").path = "/"
response.Cookies("ID") = rs("ID")
response.Cookies("ID").domain = "www." & siteLoggingIn
'response.Cookies("ID").domain = ""
response.cookies("iv")("UserName")= strUserName
If Lcase(Request.Form("Remember")) <> "" Then
response.Write("Remember Me")
response.cookies("ID").Expires = DateAdd("m",12,Date)
End If
If Not IsNull(rs("Artist")) Then
response.Cookies("Artist") = rs("Artist")
response.Cookies("Artist").domain="www." & siteLoggingIn
'response.Cookies("Artist").path = "/"
End If

russell
01-23-2007, 09:06 AM
you won't have much success setting the domain property of the cookie to a server name. needs to be sitename.com.

you are setting domain to "www.machineName" which doesn't make sense in most cases. also, take the "www" outta there.

are your sites sub-domains or actually distinct domains? for example:

-- subdomains
www. russell.webdeveloper.com
www. thechasboi.webdeveloper.com

-- distinct domains
russell.com
thechasboi.com

russell
01-23-2007, 09:21 AM
one more thing -- if the domain u set the cookie for isn't the current domain, it won't work. for example try this:

<%
Response.Cookies("aaa") = "test"
Response.Cookies("aaa").domain = "yahoo.com"
%>

cookie won't be available (unless u are yahoo.com :) ). but comment out the 2nd line and you'll see the cookie.

and while we're on the subject of testing cookies, here is a nice trick for IE.

add any page to your favorites in the links folder, doesn't matter what page. name it cookies. now go to Favorites, Organize Favorites, Links. Right-Click your new favorite and in URL paste this in javascript:alert(document.cookie) hit ok. now you'll have a button on your toolbar to examine the cookies.

thechasboi
01-23-2007, 10:56 AM
russel

Thanks for the reply. I made that change. I am not sure how this will effect the site and its subdirectories. To talk about your previous question they are completely seperate www names. I am trouble logging out my users now I made that change. I am including the log out script for your thoughts. Thanks again for the reply.
dim strvalue
'dim blvalue
dim numvalue
blvalue = "false"
numvalue = 0
strvalue = ""
response.Cookies("iv") = strvalue
response.Cookies("iv") = ""
response.cookies("iv")("cCON")= strvalue
response.cookies("iv")("cCON")= ""
response.cookies("iv")("UserName")= strvalue
response.cookies("iv")("UserName")= ""
response.cookies("ID")= numvalue
response.cookies("iv")("Name")= strvalue
response.cookies("iv")("Name")= ""
response.Cookies("Artist")= blvalue
response.Cookies("Artist")= "False"
response.Cookies("iv")("lbN")=" "
response.Cookies("iv")("lbS")= " "
response.cookies("ID").Expires=DateAdd("m",-12,Date)
response.cookies("iv").Expires=DateAdd("m",-12,Date)
response.cookies("Artist").Expires=DateAdd("m",-12,Date)

UserID = Request.QueryString("UID")
If UserID<>"" Then
UserID = Request.Cookies("UID")
End If
DeleteUser UserID 'Delete them out of the current users database
response.Cookies("UID") = ""