remember user and auto login on webform

Posted on 2004-11-10
Last Modified: 2010-04-17
Hello experts, my remember me checkbox is not working for some reason the cookie doesn't contain a value, if i try to reload the page for a second time.  Basically i want my login to function like the EE website, where a user logins in and if his credentials are valid and he checks a checkbox, set up a cookie so next time the login doesn't get displayed.  My code is not working.

'Login Page
  Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'Handles code for submit button
        lblStar.Visible = False
        lblError.Visible = False
        'jumps to the GetUser function which validates if the user exists
        If GetUser(txtUser.Text, txtPass.Text) Then
            'This function builds the cookie for each employee and sends information
            ' and is used when the Timecards webform is loaded
            GetData(txtUser.Text, txtPass.Text)
      'if checked setup a cookie to remember the employee
            If chkpasscheck.Checked = True Then
                Response.Cookies("toolname2").Value = "Accepted"
            End If
            lblError.Text = "Invalid Credentials: Please try again"
            lblError.Visible = True
            lblStar.Visible = True
        End If

   ' extra code here that finds the user from ms access database

    End Sub

 'The page that redirects too

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not Page.IsPostBack Then
                binddgforms("Select * From ToolRequest")
            End If
    End Sub
    Sub finduser()
        If Not (Request.Cookies("toolname2") Is Nothing) Then
          Exit Sub
       end if
    End Sub
Question by:tentavarious
    1 Comment
    LVL 3

    Accepted Solution

    'Sett the Cookie
    Dim cookie1 As New System.Web.HttpCookie("thiscookie", "this is the cookie value")
    cookie1.Expires = DateTime.Now.AddYears(1)

    'Read the Cookie
    If Not Request.Cookies("thiscookie") Is Nothing Then
    End If


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now