HOW TO GET THE COOKIE VALUE IN ASP.NET

marcel ethan

Total Post:105

Points:735
Posted by  marcel ethan
 1014  View(s)
Ratings:
Rate this:

I am creating a cookie and storing the value of username after succesfull login. How can I access the cookie when the website is opened. If the cookie exist I want to fill the username text box from the cookie value. And how to decrypt the value to get the username. I am doing server side validation by getting the userdetails from the database.

I am using vs 2010 with c#

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: How to get the cookie value in asp.net

    Hi marcel, 


    You may use Request.Cookies collection to read the cookies.

    if(Request.Cookies["key"]!=null)

    {

       var value=Request.Cookies["key"].Value;

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!