Hi

I am trying to view my cookie using VS 2008 having 2 textbox 1 Button 1 hyperlink.
But failed... While excuting the code it is displaying the output as -
The Vishal cookie contains: Deb
Cookie Path is /

But where actually physical cookie is stored I can't able to find. Here is my Code -

protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["cookie"] != null)
        {
            ReadCookie();
        }
    }

    protected void ReadCookie()
    {
        //Get the cookie name the user entered
        String strCookieName = Request.QueryString["cookie"].ToString();

        //Grab the cookie
        HttpCookie cookie = Request.Cookies[strCookieName];

        //Check to make sure the cookie exists
        if (cookie == null)
        {
            lblCookie.Text = "Cookie not found. <br><hr>";
        }
        else
        {
            //Write the cookie value
            String strCookieValue = cookie.Value.ToString();
            String cookiePath = Request.Cookies[strCookieName].Path;
            lblCookie.Text = "The " + strCookieName + " cookie contains: <b>" + strCookieValue + "</b><br> Cookie Path is <b>" + cookiePath + "</b><hr>";
        }
    }

try this

Request.Cookies["cookie"].Value.ToString().Trim()

regards shakeb

cookies value get in asp.net use below code

string strCookies = Request.Cookies["cookiename"].Value

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.