Hi ..
In this article I am going to explain about usage of cookies, Normally cookies are used to store temporary data. Cookies will be remain the data up to clear cookies in browser.
Using cookies we can store the user related information, also we can retrieve the information from the cookies data. Normally cookies are used to track the user. The data is stored in browser until clear the cookies.
Ex: For checking email, when enter username below they mention you want to remember username, if you checked the box then the username is stored in the cookies…same process I follow here …
Below I have mentioned the code to store the values in cookies…….
When user enter the username….write the below code..
Response.Cookies("username").Value = txtusername.Text
Also we can set expiry date for cookies
Response.Cookies("username").Expires = Now.AddDays(1)
Then page init write the below code to store the username in textbox…..
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
If Not Request.Cookies("username") Is Nothing Then
txtusername.Text = Request.Cookies("username").Value
End If
End Sub
So when store we use response and when get the data use request in cookies
I hope this one helpful to all…
Post your valuable comments……….
0 comments:
Post a Comment