Cookie is a small text file which can be used to store the user specific information for personalised the web pages. It stores the data at the user end not server side.When a browser requests a web page again,the cookie is sent along with the request.The web server then retrieves the information from the cookie.In this tutorial i will implement two types of cookie which are given below:-
1. ) Non Persistent cookie(Temporary cookie) :-
It is known as Temporary cookie.This type of cookie resides within browser memory,So it is called session cookie also.
There are some steps to implement the Non persistent cookie in ASP.NET Website which are given below:-
Step 1:- First open your visual studio--> File-->New-->Website-->ASP.NET Empty website-->OK -->open solution Explorer-->Add a New web forms --> drag and drop label,Text Box,check box,SQL Datasource and Button control on the form as shown below:-
Step 2:- Now Add a Database.mdf file --> make student table --> Add some values Id and Password as shown below:-
Note:- If you face any problem visit below link:-
Add .mdf Database on ASP.NET Website
Solve sql server problems
Step 3:- Now Double click on Login Button and Write the following codes:-
Step 4:- Now Run the Application-->Filed the required field and check the Remember Me Box as shown below:-
Step 5:-Now press login Button--.you can find the browser cookie data by clicking on certificate as shown below:-
Step 6:- Now Run again your application -->you will see that id and password field automatically filled through the cookie data as shown below:-
Note:- This type of cookie data resides in the browser memory. when we close the browser then data is lost.
2. ) Persistent Cookie:-
This type of cookie resides within client hard disk till the time ,it Expiry time is over.It stores the data in the user hard disk.
There are some steps to implement the persistent cookie on the ASP.NET website.which are given below:-
Step 1:- First open your visual studio--> File-->New-->Website-->ASP.NET Empty website-->OK -->open solution Explorer-->Add a New web forms --> drag and drop label,Text Box,check box,sql Datasource and Button control on the form as shown below:-
Step 2:- Now Double click on Login Button and write the following codes which are given below:-
Step 3:- Now Run the Application --> filled the required field details -->check the Remember Me box as shown below:-
Step 4:- Now press Login Button.see output:-
Note:- This type of cookie store the id and password Information in a text file in user hard disk.
Step 5:- To view the cookie data in computer hard disk visit following links.
For Internet Explorer:-
Windows 7 and Windows Vista has 2 cookies folders:-
C:\Users\Your User Name\AppData\Roaming\Microsoft\Windows\Cookies
C:\Users\Your User Name\AppData\Roaming\Microsoft\Windows\Cookies\Low
For chrome Browser:-
C:\Users\Your User Name\AppData\Local\Google\Chrome\User Data\Default\Local Storage
Now i am going to show you cookie data(text file)for our application.You can enter above link in any Browser or window explorer ,you can easily find cookie data(text file).
I have enter above link in window Explorer:-
C:\Users\Ramashanker\AppData\Roaming\Microsoft\Windows\Cookies
Note:- Most of the attack found on your cookie data that resides in your hard disk memory . You will have to seen many account easily compromised through client's cookie data.
.Every Browser store cookies data in different different location in your system.In persistent cookie i have used Interner Explore Browser.
For More:-
File handling in c#
Constructor and destructor
web form controls
Multithreading in c#
Main elements are used for compiling the c# code
Collections in c#
Method overloading
To Get the Latest Free Updates Subscribe
Click below for download whole application
Download