views:

163

answers:

1

I would like to know how to use session state in a simple log in log out in asp.net mvc..

I have a code here in my controller that I've retrieved from my mysql database for my session log in..but I don't really know how to manipulate it..

<AcceptVerbs(HttpVerbs.Post)> _
Function Index(ByVal username As String, ByVal password As String, ByVal department As String) As ActionResult
    Dim user As DataTable
        user = Account.userSelect(username:=username, password:=password, department:=department)
    If user.Rows.Count = 0 Then
        Return RedirectToAction("Index", "Home")
    Else
        Session("username") = user.Rows(0).Item("username")
        Session("department") = user.Rows(0).Item("department")
        Return RedirectToAction("News", "Administration")
    End If
 End Function

Thank you!

A: 

I would recommend that you look at forms authentication for asp.net mvc:

http://weblogs.asp.net/fredriknormen/archive/2008/02/07/asp-net-mvc-framework-using-forms-authentication.aspx

Shiraz Bhaiji