I've setup a method (C#) that I can call, passing it a cookie name,
then a name-value pair. The idea is that as I can't append to a cookie,
I read the cookie value, append by name=pair to the end and write it
back... which works fine for adding a single name-value pair on a page.
The problem is, I want/need to add multiple name-values pairs, the
number of which changing between pages (some might have 3, another 8).
In my test scripts I've found a major problem when trying to add even 2
pairs on a single page.
The problem is this:
- the first time I call my method, it checks the current cookie value,
which is say "loggedin=t rue"
- it then appendsthe name-value pair passed to the method ("name" and
"kevin") as a new string, i.e. "loggedin=true& name=kevin"
- I think write the new string as the value of the cookie and return to
my aspx calling page
the second time I call the method, I check the current cookie value
again (naturally), which I'd expect to be "loggedin=true& name=kevin",
but in fact it's the original value of just "loggedin=true" . This means
that when I add the second passed name-value pair (say, "gender" and
"male") the final value of the cookie is "loggedin=true& gender=male".
I say 'final', cause if I check the value of the cookie on my calling
page (i.e. without refreshing or going to another page), the value of
the cookies is STILL the original one, not the one I did with my
Response.Cookie s(...) or Response.Cookie s.Set(...) or any of the other
properties I've tried.
So, back to my original question: when exactly do cookies get written
to the browser? It seems to me that it's only when the current page is
reloaded or moved away from. Can that really be the case??
Many thanks 5 1552
The cookie is passed in the response of the header. You need to learn how to
reference the Server Variables collection.
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://www.metromilwaukee.com/clintongallagher/
"Kevin Blount" <ke**********@g mail.comwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.com.. .
I've setup a method (C#) that I can call, passing it a cookie name,
then a name-value pair. The idea is that as I can't append to a cookie,
I read the cookie value, append by name=pair to the end and write it
back... which works fine for adding a single name-value pair on a page.
The problem is, I want/need to add multiple name-values pairs, the
number of which changing between pages (some might have 3, another 8).
In my test scripts I've found a major problem when trying to add even 2
pairs on a single page.
The problem is this:
- the first time I call my method, it checks the current cookie value,
which is say "loggedin=t rue"
- it then appendsthe name-value pair passed to the method ("name" and
"kevin") as a new string, i.e. "loggedin=true& name=kevin"
- I think write the new string as the value of the cookie and return to
my aspx calling page
the second time I call the method, I check the current cookie value
again (naturally), which I'd expect to be "loggedin=true& name=kevin",
but in fact it's the original value of just "loggedin=true" . This means
that when I add the second passed name-value pair (say, "gender" and
"male") the final value of the cookie is "loggedin=true& gender=male".
I say 'final', cause if I check the value of the cookie on my calling
page (i.e. without refreshing or going to another page), the value of
the cookies is STILL the original one, not the one I did with my
Response.Cookie s(...) or Response.Cookie s.Set(...) or any of the other
properties I've tried.
So, back to my original question: when exactly do cookies get written
to the browser? It seems to me that it's only when the current page is
reloaded or moved away from. Can that really be the case??
Many thanks
Any chance you could give me a little more info? what specifically in
Server Variables should I be looking for? Do you have a site that
explains what you refer to?
Thanks for the response though, I'll check them out myself and see what
I can find, thoguh I've spent so long looking at this issue that any
help would be much appreciated.
kevin
clintonG wrote:
The cookie is passed in the response of the header. You need to learn how to
reference the Server Variables collection.
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://www.metromilwaukee.com/clintongallagher/
"Kevin Blount" <ke**********@g mail.comwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.com.. .
I've setup a method (C#) that I can call, passing it a cookie name,
then a name-value pair. The idea is that as I can't append to a cookie,
I read the cookie value, append by name=pair to the end and write it
back... which works fine for adding a single name-value pair on a page.
The problem is, I want/need to add multiple name-values pairs, the
number of which changing between pages (some might have 3, another 8).
In my test scripts I've found a major problem when trying to add even 2
pairs on a single page.
The problem is this:
- the first time I call my method, it checks the current cookie value,
which is say "loggedin=t rue"
- it then appendsthe name-value pair passed to the method ("name" and
"kevin") as a new string, i.e. "loggedin=true& name=kevin"
- I think write the new string as the value of the cookie and return to
my aspx calling page
the second time I call the method, I check the current cookie value
again (naturally), which I'd expect to be "loggedin=true& name=kevin",
but in fact it's the original value of just "loggedin=true" . This means
that when I add the second passed name-value pair (say, "gender" and
"male") the final value of the cookie is "loggedin=true& gender=male".
I say 'final', cause if I check the value of the cookie on my calling
page (i.e. without refreshing or going to another page), the value of
the cookies is STILL the original one, not the one I did with my
Response.Cookie s(...) or Response.Cookie s.Set(...) or any of the other
properties I've tried.
So, back to my original question: when exactly do cookies get written
to the browser? It seems to me that it's only when the current page is
reloaded or moved away from. Can that really be the case??
Many thanks
I forgot to ask what "The cookie is passed in the response of the
header." means in laymans terms.
Kevin
clintonG wrote:
The cookie is passed in the response of the header. You need to learn how to
reference the Server Variables collection.
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://www.metromilwaukee.com/clintongallagher/
Hi Kevin,
I believe you may be running into an issue with your format for your Cookie
values. A little background is in order.
Cookies are included in the header portion of an HTTP message, both Request
and Response. An HTTP message is pure text. The headers are lines of text
that appear before the body of the HTTP message, which in the case of a web
site or web page, is generally a container for an HTML document (although it
can also be a container for binary data such as images, etc). The text is
parsed on both ends to build the Cookies objects on the server and client.
There can be multiple cookies in an HTTP message, and each cookie may
contain multiple attributes. The Cookie header consists of one of several
different implementations , such as "set-cookie:", "cookie:", "Set-Cookie2:",
or "Cookie2:", depending upon whether the cookies are coming from server or
client, and what version is being used. This is followed by 0 or more
comma-delimited cookies.
Each cookie consists of 0 or more name=value attributes, delimited by
semi-colons. Example:
From the server:
Set-Cookie2: Customer="WILE_ E_COYOTE"; Version="1"; Path="/acme"
From the client:
Cookie: $Version="1"; Customer="WILE_ E_COYOTE"; $Path="/acme"
These are examples of Cookie headers with single cookies in them.
As you have probably figured out, your cookie *content* follows a similar
convention. This could be causing some problem in the interpretation of the
cookie, which results in it being rejected by the parser.
I would recommend using multiple cookies instead.
For more information, see: http://rfc.dotsrc.org/rfc/rfc2965.html
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist
What You Seek Is What You Get.
"Kevin Blount" <ke**********@g mail.comwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.com.. .
I've setup a method (C#) that I can call, passing it a cookie name,
then a name-value pair. The idea is that as I can't append to a cookie,
I read the cookie value, append by name=pair to the end and write it
back... which works fine for adding a single name-value pair on a page.
The problem is, I want/need to add multiple name-values pairs, the
number of which changing between pages (some might have 3, another 8).
In my test scripts I've found a major problem when trying to add even 2
pairs on a single page.
The problem is this:
- the first time I call my method, it checks the current cookie value,
which is say "loggedin=t rue"
- it then appendsthe name-value pair passed to the method ("name" and
"kevin") as a new string, i.e. "loggedin=true& name=kevin"
- I think write the new string as the value of the cookie and return to
my aspx calling page
the second time I call the method, I check the current cookie value
again (naturally), which I'd expect to be "loggedin=true& name=kevin",
but in fact it's the original value of just "loggedin=true" . This means
that when I add the second passed name-value pair (say, "gender" and
"male") the final value of the cookie is "loggedin=true& gender=male".
I say 'final', cause if I check the value of the cookie on my calling
page (i.e. without refreshing or going to another page), the value of
the cookies is STILL the original one, not the one I did with my
Response.Cookie s(...) or Response.Cookie s.Set(...) or any of the other
properties I've tried.
So, back to my original question: when exactly do cookies get written
to the browser? It seems to me that it's only when the current page is
reloaded or moved away from. Can that really be the case??
Many thanks
Search the web to find a script that will output the collection of the
ServerVariables collection. Find an application like IECookiesView or some
other method that will help you read cookies during development if your
using IE. Use Google to search the web and study. Quite frankly Firefox (FF)
is the better browser and has better web development add-ins (especially for
managing cookies).
Do some study to learn about HTTP and how a web page is requested and how
the response is sent back to the browser. Start with this article I just
found for you [1] noting the best thing I can tell a layman who I hope is
interested in becoming a competent web developer is to take words and
terminology from newsgroup articles and learn how to search the web.
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://www.metromilwaukee.com/clintongallagher/
[1] http://www.perlfect.com/articles/http.shtml
"Kevin Blount" <ke**********@g mail.comwrote in message
news:11******** **************@ s13g2000cwa.goo glegroups.com.. .
>I forgot to ask what "The cookie is passed in the response of the
header." means in laymans terms.
Kevin
>clintonG wrote:
The cookie is passed in the response of the header. You need to learn
how to
reference the Server Variables collection.
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://www.metromilwaukee.com/clintongallagher/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vince C. |
last post by:
Hi.
I'm trying to work with cookies from ASP and I've noticed cookies are stored on
my machine in two distinct forms. the first form is "Cookie:<user name>@<web
site>", which is a combination between my current logon ID and the visited web.
The second is "<name>".
I get the second form when I send a cookie from ASP script using the following
instructions:
|
by: Manjunatha |
last post by:
I created an asp page that writes to cookies and copied it to a japanese virtual folder.
The cookie writing code is below.
first.asp
var sUserId = new String();
var sPassword = new String();
var cCookieExpiryDate = "December 31, 2010";
sUserId = "manjunatha";
|
by: Marcin Gorzynski |
last post by:
Hi
Our partner is using our page in a frame. That couses a problem because our
domain is unable to issue the cookie also session does not work. each time
you click in the frame new session is created.
Is there any way that cookie can be issed , some way to go arround frames
restrictions.
Thanks for your help.
Marcin Gorzynski marcin@apartmentsapart.com
|
by: Tom |
last post by:
I know how to create a cookie using the HttpCookie.
I know about setting its domain so it can be shared.
So I have created a cookie on web site A and set it to
expire in 10 minutes.
Now I am on web site B, in VS.NET C# and I want to access
the cookie created on web site A.
|
by: Bhupesh Saini |
last post by:
I am trying to call a ASPX page using HttpWebRequest class and pass cookie information to it. My ASPX pages gets called just fine, however none of the request cookies are available to the ASPX page. What do I need to do to have the cookies sent along with the request
Below is the code snippet from the function I an using I am using to achieve the above. EVerything works except that I do not see any cookies in request object for the ASPX page...
| |
by: FishKeeper |
last post by:
I'm trying to write JavaScript code to test whether cookies are enabled
by writing a cookie and then reading its value. My code works fine in
Firefox, but it's not working in Internet Explorer 6. I have my
privacy settings set to block all cookies, but my JavaScript can read
and write cookies. Does this setting just block server cookies? That
doesn't seem right. I can't find any other settings that deal with
cookies in IE.
Here's a...
|
by: Nathan Sokalski |
last post by:
I am having trouble removing cookies that I created with my site. Here is
the code I am using to try and remove them:
If Not Request.Cookies("username") Is Nothing Then
Response.Cookies.Remove("username")
If Not Request.Cookies("password") Is Nothing Then
Response.Cookies.Remove("password")
|
by: Richard Payne |
last post by:
Hi
I'm having a problem with cookies in a virtual directory,
A cookie is created by an ASP application in the root folder i.e.
http://xxx.yyy.com
I'm unable to read this cookie in a virtual directory i.e.
https://xxx.yyy.com/mydirectory in a Visual Studio 2005 application.
|
by: knkk |
last post by:
I am not able to locate the cookies created by the setCookie function. They are not in the standard IE folder where temporary Internet files and cookies are placed. Does anyone know where I search, or how I trace them?
Also, I created cookies using this command:
$string_to_check = $type."_".$pid;
setCookie("$string_to_check", "1", time()+30*1);
The cookie doesn't expire in 30 seconds - in fact, it doesn't seem to expire at all.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |