473,385 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

problem in reading cookie

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
2 1421
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
problem solved :-)
Thanks dude..

Jan 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: pwldev | last post by:
Sorry if this isn't a good place for this question. I have a problem with losing cookie values whenever a user's local machine date/time is behind the date & time of the IIS machine. The login...
2
by: Syed Ghayas | last post by:
Hi, I've been having problem writing a cookie. Everything goes ok but when I supply the .Path property to "/" It just write the cookie when there is no cookie present, but when I try to update the...
2
by: Ian Sedwell | last post by:
Hi guys I've come across a problem with cookies. It seems that if one attempts to save several cookies in quick succession and then read them back again, you may attempt to read a cookie that...
1
by: branton ellerbee | last post by:
Cookie problem in .aspx application. I have a cookie problem that makes no sense. I get this error when the page loads: Object reference not set to an instance of an object. I am reading...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
9
by: Mike Reed | last post by:
I must be having a "senile" day! I cannot recall, nor get to work, code to read a cookie's expiration date/time in an ASP page/VBScript. What am I missing? *** Sent via Developersdex...
12
by: Patxi | last post by:
This is the first time I try to use cookies, and despite of reading some tutotials, I'm have real trouble to make it work correctly. My cookie reading code is in Master Page. When I click on a...
2
by: Sean | last post by:
I am trying to read a cookie I set but I am not sure if I really set it correctly or I am not reading it correctly. I was given the following instructions to set the cookie. It appears to be...
3
by: jacusp | last post by:
Hi, I have problem with reading cookies. I'd like to save fields of my form into cookies and use them by another page. I save cookies: foreach ($_POST as $idx =$value) { setcookie($idx,...
8
by: LayneMitch via WebmasterKB.com | last post by:
I'm supposed to develop a page that asks info as form values and when you hit "submit" it takes you to a page that reads the values you entered into the first page and displays those values in a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.