473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Cookies not saving

I've copied and pasted simple code to create a cookie but it never saves the
cookie. Is there something you have to set in the web.config file to use
cookies? Here is the simple code....

Dim cook1 As New HttpCookie("MyCookie")

Dim now As DateTime = DateTime.Now

cook1.Expires = now.AddDays(30)

cook1.Values.Add("MyCookie", "Joe Bob")

Response.Cookies.Add(cook1)

Mike


Nov 18 '05 #1
3 2943
Your code looks fine. Most likely it is a browser issue.

Have you confirmed that your web browser is accepting cookies?

Are you sure you are looking for the cookie in the right place?

Have you tried using a different browser, i.e. Netscape?
--
Peter O'Reilly
Nov 18 '05 #2
Well, found out what my problem was. Lets say my server name was test1 and
my domain is mydomain.com. In the url to test it I would type
http://test1/testapp/WebForm1.aspx to get the page up. The cooke would not
work with this url. If I used
http://test1.mydomain.com/testapp/WebForm1.aspx, the cookie would work
correctly.

Mike
"Peter O'Reilly" <Pe***********@timeinc.com!N!O!.S!P!AM!> wrote in message
news:uB*************@tk2msftngp13.phx.gbl...
Your code looks fine. Most likely it is a browser issue.

Have you confirmed that your web browser is accepting cookies?

Are you sure you are looking for the cookie in the right place?

Have you tried using a different browser, i.e. Netscape?
--
Peter O'Reilly

Nov 18 '05 #3
That's correct. Cookies work with domain names only as per the HTTP cookie
specification:
http://wp.netscape.com/newsref/std/cookie_spec.html
--
Peter O'Reilly
Nov 18 '05 #4

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

Similar topics

2
by: Ian Sedwell | last post by:
Hi guys I've come across a problem with cookies. It seems that if one attempts to save several cookies in quick succession and then read them back again, you may attempt to read a cookie that...
5
by: anony | last post by:
Hi, I have a site that uses forms authentication to secure the directory. The site behaves as expected when viewed externally... if I close the browser and attempt to access it again, I get...
3
by: Mike Johnson | last post by:
I've copied and pasted simple code to create a cookie but it never saves the cookie. Is there something you have to set in the web.config file to use cookies? Here is the simple code.... Dim...
2
by: Simple Person | last post by:
I am using C# in ASP (Microsoft Visual Studio.Net) to try and create a cookie. I have cookies enabled on both of my computers, but when I use the following code (I have also tried the commented line...
3
by: Brian Kitt | last post by:
Ok. I know this sounds like a stupid question, but I'm really beside myself here. I've worked with cookies for years, so I know how they work, but I am new to C#, so apparently I'm doing...
0
by: David | last post by:
Hi all, I have to screen scrape a site to put into our templates. (We have the site owners permission). The site has a login screen, and I can successfully post credentials using...
4
by: Brano | last post by:
HI all, I have this problem I have two pages on one I use this code to set some cookies: Response.Cookies("cokFirstName").Expires = DateTime.MaxValue Response.Cookies("cokFirstName").Value =...
3
by: Jimmy | last post by:
I'm trying to find a website that does the following: 1. Signs you up to a second site under a different primary domain (i.e. as a result of a checkout or something). The username and password may...
1
by: Keld | last post by:
I have a problem with saving values into cookies. In a grid i have a imagebutton which which rowcommand looks like this Dim BookMarkCookie As New HttpCookie("BookMarks") BookMarkCookie.Value...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
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,...
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...
0
agi2029
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,...
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...

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.