We provide IT Services

Register Now Click On

Read More Tutorials Click On

Post Page Advertisement [Top]


What is Cookies in Asp .net 

Cookies is the small text file save in client browser or machine. Store the information client blower just like Name Password etc..

type of cookies:-

There are two types of cookies:-

1.Persist Cookies.
2.Non-Persist Cookies

Non-Persist Cookies:- The user fill the information in web form name age mobile etc.. this information save the 
browser memory temporary time. The browser close data is lost this type of cookies is Non Persist Cookies.




Persist Cookies :- Persist Cookies the user fill the information in web form just like  name password etc.. then this information store the small text file in the browser memory.this text file does not remove after close browser.


Example:-


   

       

           

               
                    User Name
                   
                   
               

               
                    Password
                   
                   
               

                 
                   
                   
                     
               
           
       
   


.CS page coding:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace cookes
{
    public partial class cookes1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn1_Click(object sender, EventArgs e)
        {
            Response.Cookies["Uname"].Value = TextUname.Text;
            Response.Cookies["Password"].Value = TextPassword.Text;
            Response.Cookies["uname"].Expires = DateTime.Now.AddDays(2);
            Response.Cookies["Password"].Expires = DateTime.Now.AddDays(2);
        }

        protected void btn2_Click(object sender, EventArgs e)
        {
            Lebel1.Text = Request.Cookies["Uname"].Value;
            Label2.Text = Request.Cookies["Password"].Value;
        }
    }
}
| Designed by Rockprogrammer