Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 7th, 2004, 02:52 PM
Registered User
 
Join Date: Apr 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help: Cookies not getting set (c#)

Hi all,

I am trying to create cookies on the login page and then redirect the user to the next page using Response.Redirect. But I am unable to read Request.Cookies on the next page.

I do not understand what the problem might be. I checked the webconfig file to confirm that the cookies are enabled.

I am using the following code for saving the cookie:

HttpCookie MyCookie = new HttpCookie("Background");
MyCookie.Value = "blue";
DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(1,30,0,0,0);
MyCookie.Expires = dt + ts;
Response.Cookies.Add(MyCookie);

AND the following code for reading it:
HttpCookie cookie = Request.Cookies["Background"];
if (cookie != null)
{
    string b= cookie.Value.ToString();
    Response.Write("Background is :"+ b);
}
else
{
    Response.Write("Cookie not found. <br>");
}


Please help me debug this.

Thanks in advance,
Meetali.







Similar Threads
Thread Thread Starter Forum Replies Last Post
XPath: set operation with a disjoint node set rich_unger XSLT 7 May 6th, 2008 09:24 AM
how Set Multiple values in cookies amol_0008 JSP Basics 1 May 31st, 2007 06:27 AM
Help: Cookies not getting set (c#) meetali ASP.NET 1.0 and 1.1 Professional 5 April 8th, 2004 01:13 PM
Can't set cookies meckeard ASP.NET 1.0 and 1.1 Basics 7 September 8th, 2003 12:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.