473,467 Members | 1,565 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

cookie troubles

I have a web app that is a mixture of ASP and ASP.NET pages. Largely the
only data passed between them is via the querystring, or by reading from a
database. However there is a requirement for one part to communicate via a
cookie. (Please dont ask me to go into why, I don't have time).

In my ASP page, I created a cookie and put a value in it:

Response.Cookies("MyCookieName") = "OriginalValue"
Response.Cookies("MyCookieName").Expires = CDate("31/12/2030")
Response.Cookies("MyCookieName").Path = "/"

That works great. The cookie appears in the Temporary Files folder on disk,
with the distant expiry date as expected. Furthermore I look inside the
cookie using Notepad, and it shows the "OriginalValue" that I put in.

Now I want to read that same cookie from my ASP.NET page, using:

Dim CookieVal as String = Request.Cookies.Item("MyCookieName").Value

....which seems to work perfectly OK. It returns "OriginalValue" that I put
in there using ASP.

Now, the problem is that I cannot seem to *update* the cookie via my ASP.NET
page:

Dim c As HttpCookie = Request.Cookies.Item("MyCookieName")
c.Value = "MyNewValue"
After running the above code, I take a look inside the cookie, but the
"OriginalValue" remains. No errors occurred, it did not crash, but didn't
work either. I cannot understand why.

What am I missing?

Thanks
Owen
PS. replies cc'd via email appreciated as this is quite urgent
ow************@mantix.com
Nov 19 '05 #1
1 988
"Owen" wrote:
Now, the problem is that I cannot seem to *update* the cookie via my
ASP.NET
page:

Dim c As HttpCookie = Request.Cookies.Item("MyCookieName")
c.Value = "MyNewValue"


IIRC, you should add : Response.Cookies.Add(c);

Steven

- - -
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ben Hearsum | last post by:
I'm confused about the way Cookie.load outputs cookies. Is there a way I can tell it to give me the value of a key? I set my cookie like this: mycookie = Cookie.SimpleCookie() mycookie =...
5
by: brettr | last post by:
When I reference document.cookie, there is a long string of key=value; pairs listed. I may have 100 hundred cookies on my hard drive. However, most only have one key=value pair. Does the...
4
by: socialism001 | last post by:
I'm trying to store a value in a cookie but its not working. Can anyone see what I might be doing wrong. Thanks, Chris ~~~~~~~~~~~~~~~~~~ <script language="javascript">...
9
by: Marco Krechting | last post by:
Hi All, I have a page with a list of hyperlinks. I want to save information in a cookie about the fact that I entered an hyperlink or not. When I click one of the hyperlinks I want this stored...
7
by: ehendrikd | last post by:
hi all i need some clarification on how the php session work in relation to cookies. we have a web site where users need to log in. a few of our users were having troubles with their browser...
0
by: csgraham74 | last post by:
Hi, Im trying to make changes to an appliction that i inherited. i have set several cookies with different small values from XML. i get to a piece of code where i response.redirect to another...
2
by: RootShell | last post by:
I have been experiencing a lot of troubles in reading a PHP COOKIE from javascript. if i write the cookie and read it in javascript in the same PHP file it works well, but if i write the cookie...
4
by: gcervantes | last post by:
Hello, I am making a screen scraper, in other programs I have been able to log into a site, get the cookie, submit a form and read the results. However, this time I am in troubles, the site I need...
9
by: ziycon | last post by:
I am creating a cookie when a user clicks on a link and saving a value based on the link clicked, everytime the user goes to a different page i want the JS to check if the cookie already exists and...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.