473,386 Members | 1,630 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,386 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 2939
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.