Cookies only work on localhost?

  • Thread starter Alan Draper via .NET 247
  • Start date
A

Alan Draper via .NET 247

I have the following code, which should show "No Cookie Set" the first time you visit, and then show the last time you visited each consecutive time. Should be simple, right...

const string COOKIE_NAME = "TestCookie";
private void Page_Load(object sender, System.EventArgs e) {
HttpCookie cookie = Request.Cookies[COOKIE_NAME];
txtOut.InnerHtml = ( cookie == null ) ? "No Cookie Set" : cookie.Value;

cookie = new HttpCookie( COOKIE_NAME, DateTime.Now.ToString() );
Response.Cookies.Add( cookie );
}

... but it is only working when I view it on http://localhost. When I look at http://myserver.mydomain.com, I get "No Cookie Set" over and over. Anyone have any ideas?

Thanks -- Alan

P.S. I've tried changing the settings on my browser to allow all cookies. Didn't help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

cookies.... 1
Cookies 1
cookies not persisting 2
Cookies 1
cookie.domain bug?? 2
Sessions and Cookies dont work 2
Help on cookies ? 4
problem with cookies and graphics 0

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top