Solved

Cookie appending problem

Posted on 2004-09-29
2
231 Views
Last Modified: 2010-04-17
I am modifying an ASP program and need to add a cookie which will keep track of where a person as last visited.  Lets say the Cookie will be called loc.

With the following code getting executed whenever a user changes his location:

        Response.Cookies("loc") = locID
                  Response.Cookies("loc").Expires = Now() + 50

locID is a varible which can run from 1 to 12.  On the first save of this cookie, it does OK.  After than it appends the came name in the cookie with the new value.   Thus you have after the second selection, 2 enties for loc.  In retrieving the cookie for loc, it reads the first occurrence.  What is the way to prevent having the multiple entries for the same cookie?
0
Comment
Question by:garyervin
2 Comments
 
LVL 3

Expert Comment

by:PodExpert
ID: 12183546
Every cookies is defined by following information:

- name
- domain (default: domain of the server, e.g. yahoo.com)
- path (default: root - all scripts in the domain have access to the cookie)

If you are creating cookies from different domains [or subdomains!] (your scripts are in different domains), then it might be the problem - in fact, you are creating two different cookies (with the same name, but different domains). Try explicitly change the Domain and Path properties of the cookies to information, that is common to all scripts. If your scripts are in domains aaa.domain.com and bb.domain.com, then the domain should be set to domain.com. Path should be set to "/".

Regards.
P.
0
 

Accepted Solution

by:
sudarshan_sharma22 earned 125 total points
ID: 12214915
Cookies are appended into the Headers. Hence there can be more then one cookie.
Hence when ever you do (Response.Cookies("loc") = locID) a cookie with name "loc" is appened to the headers.

Hence the result that you get two cookies with the same name "loc". So what you need to do is that delete the first cookies if its present or you need to modify that cookie.



An alternate way to your problem is to use the header "Referer", that gives the URL from which the page is viisted. (this will directly give you the url of the page and then u need to decode that appropriately ( from 1 to 12 whatever might be ur logic).

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Arduino EDI - Programming language 3 80
recursion example 16 111
detecting  the added row index in a datagridview 3 61
simplest php form 3 63
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now