Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem reading cookies

Status
Not open for further replies.

jasonsalas

IS-IT--Management
Jun 20, 2001
480
GU
Hi everyone,

I just deployed a cookie-based script which worked fine locally on PWS to an NT server, but anything having to do with cookies isn't working. Actually, I've noticed that I can write a cookie and retrieve it's values within the same page, but I can't persist it and extract values from page to page.

In particular, I'm having users register on a page, which takes their values, writes them to a cookie, and then passes them to another page, displaying a customized message. But because the main page detects for the presence of the cookie first, the values aren't persisting, the page gets stuck in a loop, continually going back to the registration page, not finding the cookie.

I've racked my brain, and this really throws a wrench in my app's architecture. Here's a portion of how I'm writing a cookie to a page:

Response.Cookies("candidateOfTheDay")("firstName") = objRS("FirstName")
Response.Cookies("candidateOfTheDay")("lastName") = objRS("LastName")
Response.Cookies("candidateOfTheDay")("graphic") = objRS("GraphicURL")
Response.Cookies("candidateOfTheDay")("party") = objRS("Party")
Response.Cookies("candidateOfTheDay")("officeSeeking") = objRS("OfficeSeeking")
Response.Cookies("candidateOfTheDay")("candidateID") = objRS("CandidateID")
Response.Cookies("candidateOfTheDay")("officeSeeking") = objRS("OfficeSeeking")
Response.Cookies("candidateOfTheDay").Expires = expireDate

For Each objCK In Request.Cookies
Response.Write objCK & &quot; = &quot; & Request.Cookies(objCK) & &quot;<br>&quot;
Next

Thanks for the help!
 
I think so. It's in a subdirectory from root. Would it make a big difference> I thought cookies should work in any directory, as long as ASP in enabled on the Web server.
 
I do believe so. It's in a subdirectory from root. Do you think it would make a big difference? I thought cookies should work in any directory, as long as ASP in enabled on the Web server.
 
if its not in a virtual directory then the cookies may not work, i had a similar problem before but with client side cookies, as soon as i made the directory in IIS a virtual one all the cookie code started working.
 
Hi sjravee,

I'm in discussions with my third-party Web host provider to find out if they can convert this directory over to a virtual directory. I(f possible, I thik it'll work.

If I have this done, will this screw up then files currently contained within it...or the rest of my site? I would hope not...
 
no, it wont screw things up. You should check with your Web host provider to see if they support asp because thats essentially what you are writing this code in.If they do and your files are currently in a VD then something else may be the problem
 
Thanks. I had my Web host convert the dir to a virtual directory, and I still can't persist cookie information. It's really frustrating. Got any other ideas?
 
Hi sjravee,

I think I found the problem, and I've been able to resolve it. If you look at my original codeblock, I wasn't speciyfing the Path property of the cookie object. This came to mind and so I wrote it out explcitly, and now it works, only making the cookie's values applicable to pages and folders within the subdirectory.

Response.Cookies(&quot;candidateOfTheDay&quot;).Expires = Date() + 1
Response.Cookies(&quot;candidateOfTheDay&quot;).Path = &quot;/decision2002&quot;

Thanks for all your help! :)

A friend in Guam,
Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top