본문 바로가기

ASP.NET

asp.net 쿠키 확인


    protected void fillTopInfo()
    {
        StringBuilder sb = new StringBuilder();

        //int loop1, loop2;
        //HttpCookieCollection MyCookieColl;
        //HttpCookie MyCookie;
        //MyCookieColl = Request.Cookies;

        //// Capture all cookie names into a string array.
        //String[] arr1 = MyCookieColl.AllKeys;

        //// Grab individual cookie objects by cookie name.
        //for (loop1 = 0; loop1 < arr1.Length; loop1++)
        //{
        //    MyCookie = MyCookieColl[arr1[loop1]];
        //    sb.Append("Cookie: " + MyCookie.Name + "<br>");
        //    sb.Append("Expires: " + MyCookie.Expires + "<br>");
        //    sb.Append("Secure: " + MyCookie.Secure + "<br>");

        //    //Grab all values for single cookie into an object array.
        //    String[] arr2 = MyCookie.Values.AllKeys;

        //    //Loop through cookie Value collection and print all values.
        //    for (loop2 = 0; loop2 < arr2.Length; loop2++)
        //    {
        //        sb.Append("Value" + loop2 + ": " + Server.HtmlEncode(arr2[loop2]) + "<br>");
        //    }
        //}

        HttpCookieCollection cookies = Request.Cookies;
        for (int n = 0; n < cookies.Count; n++)
        {
            HttpCookie cookie = cookies[n];
            sb.Append("<hr/>Name: <b>" + cookie.Name + "</b><br />");
            sb.Append("Expiry: " + cookie.Expires + "<br />");
            sb.Append("Value: " + cookie.Value + "<br />");
            sb.Append("Secure?: " + cookie.Secure + "<br />");
            sb.Append("Domain: " + cookie.Domain + "<br />");
            sb.Append("Path: " + cookie.Path + "<br />");
        }


        Label CookiesText = (Label)Master.FindControl("CookiesText");
        CookiesText.Text = "u_id = [" + common.getCookieValue("maxmovie","u_id") + "]<BR><BR><BR>";
        CookiesText.Text += common.getCookieValue("song2taiji_080819") + "<BR><BR><BR>";
        CookiesText.Text += sb.ToString();
           

    }