problem in reading cookie

J

jack

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);
}
 
D

Danana

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.
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top