Hi,
What is the cookie can you give example???
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jul 26, 2012, 12:41 AM
Hi,
Cookies are also known by many names, HTTP Cookie, Web Cookie, Browser Cookie, Session Cookie, etc. Cookies are one of several ways to store data about web site visitors during the time when web server and browser are not connected. Common use of cookies is to remember users between visits. Practically, cookie is a small text file sent by web server and saved by web browser on client machine.
Cookies may be used for authentication, identification of a user session, user's preferences, shopping cart contents, or anything else that can be accomplished through storing text data. Cookies can also be used for travelling of data from one page to another.
please refer
http://msdn.microsoft.com/en-us/library/78c837bd.aspx
http://asp.net-tutorials.com/state/cookies/
hope this will help you.
Satyapriya NayakPosted Jul 25, 2012, 12:53 PM
Cookies: - Cookies are little pieces of information that a server stores on a browser. They are of two types
Temporary cookie: - They are also known as session cookies. These are volatile in nature. When the browser is shutdown they are erased.
Persistent cookie:- These may be called as permanent cookies. These are especially saved in files. It may remain for a month or year.
Properties of cookies
Some properties of cookie
Name: - represent the name of cookie.
Name value: - represent a collection of key values of cookie
Domain: - represent the domain associated with a specific cookie.
Path: - the path associated with a cookie.
Expires: - expired time of cookie.
Hashkey: - identifies whether the cookie is a cookie dictionary.
Secure: - specifies whether the cookie is to be sent in an encrypted connection or not.
Working with cookies
Cookies are send back and forth between a browser and server. The server creates a cookie by using the set cookie header. Subsequent request from the browser is send to the server in cookie header. Suppose the server create a cookie
Set cookie: username=rajkumar; path=1;domain=abc.com; expires=Friday, 19th august 20116:30:00GMT
The server creates the cookie named as username containing the user information. Path identifies any requested page to the website, domain identifies the specific website abc.com, expired identifies that this cookie would be expired on the specific data mentioned.
After the server creates the cookie the response is send to the server from the browser for each subsequent request to the webpage. The reader sends in the format cookie: username=raj+kumar
The server is using set cookie reader. The browser is using reader.
Creation and reading session cookies
The session cookies can be created by using the response object and can be read by using the request object. The cookies properties of the response and request objects contains instances of Httpcookies collection class. Each cookie is created by using Httpcookie class.
For creating cookies
Dim cookies1 As New HttpCookie("raj", "kumar")
Response.Cookies.Add(cookies1)
For reading cookies
Response.Write(request.cookies(cookies1).value)
Program
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'For creating cookies
Dim cookies1 As New HttpCookie(TextBox1.Text, TextBox2.Text)
Response.Cookies.Add(cookies1)
clear()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
'For reading cookies
Dim s As String
For Each s In Request.Cookies
Label1.Text += "- "
& s
Next
End Sub
Sub clear()
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
End Class
Persistence cookies
It is saved in a config file.it has a specific expiration date. It is especially used to store information about userid, name of authenticated user.
For creating persistence cookie
Dim pcookie1 as New HttpCookie("user name"."ravi kumar")
Response.Cookies.Add(pcookie1)
pcookie1.expires= #19/06/2011#
For reading persistent cookie
Response.Write(Request.cookies("user name").Value)
Limitation of cookies: -
1.A cookie can store maximum of 4kb of data.
2.A cookie can contain only string values. It can contain objects like dataset object.
3.A cookie is browser dependent.
4.Persistent cookie may be deleted before expiration date by browser.
Thanks