asp.net : how to automatically identify user / returning user
i see a lot of web site that.. remember when i return without using registration. I think they save cookies or something... So i'm asking you: in asp.net / vb.net how can i save the id of a user ? What are the command to d开发者_C百科o this ? Thanks in advance...
You need to use cookies.
MSDN - http://msdn.microsoft.com/en-us/library/ms178194.aspx
Here is some VB.NET to read/write cookies. Pretty straight forward:
Sub SubmitBtnWrite_Click(Sender As Object, E As EventArgs)
Response.Cookies("TestCookie1").Expires = "5/1/2010"
Response.Cookies("TestCookie1").Value = _
"The cookie stuff."
Response.Cookies("TestCookie2").Expires = "5/1/2010"
Response.Cookies("TestCookie2").Value = _
"More cookie stuff." End Sub
Sub SubmitBtnRead_Click(Sender As Object, E As EventArgs)
Dim I as integer
For I = 0 to Request.Cookies.Count - 1
lblMessage1.Text = lblMessage1.Text _
& Request.Cookies.Item(I).Name & ": " _
& Request.Cookies.Item(I).Value & "<BR>"
Next End Sub
SLaks is correct - use cookies. The Login control has this functionality built in.
精彩评论