By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,354 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,354 IT Pros & Developers. It's quick & easy.

problem in reading cookie

P: n/a
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);
}

Jan 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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);
}


Jan 10 '06 #2

P: n/a
problem solved :-)
Thanks dude..

Jan 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.