Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > problem in reading cookie

Reply
Thread Tools

problem in reading cookie

 
 
jack
Guest
Posts: n/a
 
      01-10-2006
HI . i have created a cookiie in one page and i am trying to get in
other page .. but not getting to desired result.

im able to create cookie and reade it in the same page but not able to
get or read it on the redirected page ..
below is my code ..


webform1.aspx
private void Button1_Click(object sender, System.EventArgs e)
{
HttpCookie c = new HttpCookie ("mycookies","this is the content of
my cookie");
Response.Cookies.Add (c);
Response.Redirect("WebForm2.aspx");
}
webform2

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write ( Response.Cookies.Count);
Response.Write ( Response.Cookies["mycookies"].Value);
}

 
Reply With Quote
 
 
 
 
Danana
Guest
Posts: n/a
 
      01-10-2006
Hi Jack,

To read a cookie back from a client you need to use the Request.Cookies
collection.

E.g. Response.Write ( Request.Cookies.Count);

That's it really!

Hope this helps.

jack wrote:
> HI . i have created a cookiie in one page and i am trying to get in
> other page .. but not getting to desired result.
>
> im able to create cookie and reade it in the same page but not able to
> get or read it on the redirected page ..
> below is my code ..
>
>
> webform1.aspx
> private void Button1_Click(object sender, System.EventArgs e)
> {
> HttpCookie c = new HttpCookie ("mycookies","this is the content of
> my cookie");
> Response.Cookies.Add (c);
> Response.Redirect("WebForm2.aspx");
> }
> webform2
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> Response.Write ( Response.Cookies.Count);
> Response.Write ( Response.Cookies["mycookies"].Value);
> }


 
Reply With Quote
 
 
 
 
jack
Guest
Posts: n/a
 
      01-12-2006
problem solved
Thanks dude..

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is different between Request.Cookie and Response.Cookie ad ASP .Net 2 01-27-2006 12:54 PM
Cookie Question (IP as domain and cookie file location) =?Utf-8?B?UGF1bA==?= ASP .Net 1 01-10-2006 08:37 PM
Any downsides to cookie assignment inside custom class using HttpContext.Current? ASP.NET 2.0 cookie fix? ASP .Net 2 08-17-2005 06:43 AM
Cookie and Session Cookie Questions. Shapper ASP .Net 1 04-27-2005 11:20 AM
Session cookie? Browser instance cookie? Ben ASP .Net 3 06-03-2004 03:41 AM



Advertisments