locked
session in vb code RRS feed

  • Question

  • User-619595341 posted


    hellos, i have a login thing which allows user to login into the system.

    codes for it:


    Partial Class Login
        Inherits System.Web.UI.Page
        Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
            Dim UserController As New BusinessLogic.UserBLL
            Dim ds As System.Data.DataSet = UserController.getUser(Login1.UserName.ToString, Login1.Password.ToString)
            If ds.Tables(0).Rows.Count > 0 Then
                e.Authenticated = True
            Else
                e.Authenticated = False
            End If
        End Sub

    Partial Class Login
        Inherits System.Web.UI.Page
    
        Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
    
            Dim UserController As New BusinessLogic.UserBLL
            Dim ds As System.Data.DataSet = UserController.getUser(Login1.UserName.ToString, Login1.Password.ToString)
            If ds.Tables(0).Rows.Count > 0 Then
                e.Authenticated = True
            Else
                e.Authenticated = False
            End If
    
        End Sub


    i wanna use Session to store the username of the user who logs into the system. how to do that? i tried inserting the codes below on page_load.


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
    
            Dim UserController As New BusinessLogic.UserBLL
            Dim ds As System.Data.DataSet = UserController.getUser(Login1.UserName.ToString, Login1.Password.ToString)
    
            Session("username") = Login1.UserName.ToString
    
    
    
       


    actually i dont know what i am doing. i do until blur.


    so when user successively logs into the system, he/she will be redirect to the MainPage.aspx.


    in the page, (MainPage.aspx), there will be a label (lb_user) that shows the name of the user who has logged into the system.

    lb_user.Text = Session("admin")


    i tried to use that to show the user name in the label but it doesnt seem to work.


    im using vs2008 and sqlexpress by the way.


    please help thanks

    Tuesday, December 8, 2009 11:14 AM

Answers

  • User-1028151323 posted

    There are controls for doing exactly what you're trying to accomplish. Take at look at these articles:


    http://aspnet.4guysfromrolla.com/articles/120705-1.aspx


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 8, 2009 12:46 PM