| | |
How To Create A Remember Me Cookie
Thread Solved |
•
•
Join Date: Jun 2005
Posts: 50
Reputation:
Solved Threads: 0
I am using aspx.vb to create a login page. I would like to create a remember me cookie using a checkbox that will help to remember user ID but will also allow it to be destroy if a different user ID wants to log in with the same computer, but i have no idea how to start. Any assistance? Thank you! :cry:
You might start with Forms Authentication in .NET. It automates the "remember me" cookie with the following method call.
Here's a place to begin learning more:
MSDN Documentation for SetAuthCookie Method
Cheers,
- Steve
ASP.NET Syntax (Toggle Plain Text)
FormsAuthentication.SetAuthCookie(userName, saveLogin);
MSDN Documentation for SetAuthCookie Method
Cheers,
- Steve
•
•
Join Date: Jan 2010
Posts: 1
Reputation:
Solved Threads: 0
0
#3 Jan 18th, 2010
here is some code you can find it use full
[URL snipped]
ASP.NET Syntax (Toggle Plain Text)
Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then 'Check if the browser support cookies If Request.Browser.Cookies Then 'Check if the cookies with name PBLOGIN exist on user's machine If Request.Cookies("PBLOGIN") IsNot Nothing Then 'Pass the user name and password to the VerifyLogin method Me.VerifyLogin(Request.Cookies("PBLOGIN")("UNAME").ToString(), Request.Cookies("PBLOGIN")("UPASS").ToString()) End If End If End If End Sub Protected Sub BtLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) 'check if remember me checkbox is checked on login If (Me.CbRememberMe.Checked) Then 'Check if the browser support cookies If (Request.Browser.Cookies) Then 'Check if the cookie with name PBLOGIN exist on user's machine If (Request.Cookies("PBLOGIN") Is Nothing) Then 'Create a cookie with expiry of 30 days Response.Cookies("PBLOGIN").Expires = DateTime.Now.AddDays(30) 'Write username to the cookie Response.Cookies("PBLOGIN").Item("UNAME") = Me.TbUserName.Text 'Write password to the cookie Response.Cookies("PBLOGIN").Item("UPASS") = Me.TbPassword.Text 'If the cookie already exist then wirte the user name and password on the cookie Else Response.Cookies("PBLOGIN").Item("UNAME") = Me.TbUserName.Text Response.Cookies("PBLOGIN").Item("UPASS") = Me.TbPassword.Text End If End If End If Me.VerifyLogin(Me.TbUserName.Text, Me.TbPassword.Text) End Sub Protected Sub VerifyLogin(ByVal UserName As String, ByVal Password As String) Try 'If login credentials are correct 'Redirect to the user page 'else 'prompt user for invalid password 'end if Catch ex as System.Exception Response.Write(ex.Message) End Try End Sub Protected Sub lbSignout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbSignout.Click 'Check iIf the cookies with name PBLOGIN exist on user's machine If (Request.Cookies("PBLOGIN") IsNot Nothing) Then 'Expire the cookie Response.Cookies("PBLOGIN").Expires = DateTime.Now.AddDays(-30) End If 'Redirect to the login page End Sub End Class
[URL snipped]
Last edited by Ezzaral; Jan 18th, 2010 at 1:00 pm. Reason: Added code tags and snipped url. Keep it organized and keep it on site.
![]() |
Similar Threads
- Forms Authorization/ Authentication using asp .net and vb .net (ASP.NET)
- Passing data from forms from one page to another (JavaScript / DHTML / AJAX)
- Create .aspx page at runtime (ASP.NET)
- Shut Down And Saving Your Settings (Windows NT / 2000 / XP)
- cookie spoofing (Database Design)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- Have I been activated? (Geeks' Lounge)
- cookie matter (Database Design)
Other Threads in the ASP.NET Forum
- Previous Thread: vb.net help codes
- Next Thread: What's the best SEO blog software?
Views: 16731 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.aspx .net 2.0 3.5 ajax appliances asp asp.net asp.net-mvc authentication blog browser button c# chat checkbox click complex connectionstring control crystal database datagridview datagridviewcheckbox datalist db deadlock deployment development dgv directshow dom download dynamic edit event-bubble-up feedback findcontrol flash form forms grid gridview hosting iframe iis iis-application impersonation india javascript knowledge-required languages list locahost-email login mac menu mobile mtom navigation novell offline opener opera picturebox problem profile redirect refresh remember-me response.redirect result richtext role save search server service session silverlight sql sql-server stop-sql-injection translate treeview trust-level update validation vb vb.net video view vista visual-studio visualstudio vs2008 web website xml xsl





