How can i make it so my c# application gets cookie data when it uses http so it can be stored for the next page.
For example, it logs in.. Then it enters another webpage which requires the same data received from when logging in.
Here is the code:
How can i make it so my c# application gets cookie data when it uses http so it can be stored for the next page.
For example, it logs in.. Then it enters another webpage which requires the same data received from when logging in.
Here is the code:
Here are a few examples of creating and retrieving cookies.
Automatic Cookie Handling C#/.NET HttpWebRequest+HttpWebResponse
http://msdn.microsoft.com/en-us/library/dd920298(v=vs.95).aspx
It's advisable to avoid storing sensitive data in cookies. If you are, then at least encrypt it using something like AesCryptoServiceProvider: http://msdn.microsoft.com/en-us/library/system.security.cryptography.aescryptoserviceprovider.aspx
hopefully this helps.
Add Cookie :
HttpCookie aCookie = new HttpCookie("userName");
aCookie.Value = "pranay";
aCookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(aCookie);
Retrieve Cookie :
if(Request.Cookies["userName"] != null)
{
HttpCookie aCookie = Request.Cookies["userName"];
Label1.Text = Server.HtmlEncode(aCookie.Value);
}
Have you thought about using querystring data?
yourUrl.aspx?username=mrWonderful&password=myPass
and then parse that login data on the next page.