alert('Oh shit !!!! Javascript is disabled!!!! ');


Blog Archive

Cookies in ASP.NET

Cookies in ASP.NET

A cookie is a small bit of text file that browser creates and stores on your machine (hard drive). Cookie is a small piece of information stored as a string. Web server sends the cookie and browser stores it, next time server returns that cookie .Cookies are mostly used to store the information about the user. Cookies are stores on the client side .To store data in a cookie is not secure due to it's location at client end. Cookie was introduced with first version of Netscape navigator (that was 1.0). 

Advantages

  1. Cookies do not require any server resources since they are stored on the client.

  2. Cookies are easy to implement.

  3. You can configure cookies to expire when the browser session ends (session cookies) or they can exist for a specified length of time on the client computer (persistent cookies).

Disadvantages

  1. Users can delete a cookies.

  2. Users browser can refuse cookies ,so your code has to anticipate that possibility.

  3. Cookies exist as plain text on the client machine and they may pose a possible security risk as anyone can open and tamper with cookies.

.ASPX CODE




<html xmlns="http://www.w3.org/1999/xhtml" > 
<head id="Head1" runat="server">
<title></title>
</head> 

<body> 
<form id="form1" runat="server">
<div> 
<fieldset>
<legend>rdfdf</legend>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Add" Width="70px"
onclick="Button1_Click" /> <asp:Button ID="Button2" runat="server" Text="View" Width="84px"
onclick="Button2_Click" /> <br /> <br /> <asp:Label ID="Label1" runat="server" Text="" Width="138px"></asp:Label> </fieldset> </div> </form> </body> </html>