Dim _objStudentInfo As StudentInfo = New StudentInfo(Txtuserid.Text, Txtpassword.Text) Session("objStudentInfo") = _objStudentInfo Dim con As SqlConnection con = New SqlConnection("server=***;user id=sa;password=***;database=***") con.Open() Dim cmd As SqlCommand Dim rdr As SqlDataReader cmd = New SqlCommand("select USRMST_USERLOGID,USRMST_PASS from [SYSTEM].[SYSTEM_USER_LOGIN] where USRMST_USERLOGID='" + Txtuserid.Text + "' And USRMST_PASS='" + Txtpassword.Text + "'", con) rdr = cmd.ExecuteReader() While rdr.Read() If rdr("USRMST_USERLOGID").ToString() = Txtuserid.Text AndAlso rdr("USRMST_PASS").ToString() = Txtpassword.Text Then SingleSessionPreparation.CreateAndStoreSessionToken(Txtuserid.Text) Dim sKey As String = Txtuserid.Text + Txtpassword.Text Dim sUser As String = Convert.ToString(Cache(sKey)) If sUser Is Nothing OrElse sUser = [String].Empty Then Dim i = HttpContext.Current.User Dim SessTimeOut As New TimeSpan(0, 0, HttpContext.Current.Session.Timeout, 0, 0) HttpContext.Current.Cache.Insert(sKey, sKey, Nothing, DateTime.MaxValue, SessTimeOut, System.Web.Caching.CacheItemPriority.Normal, Nothing) Dim context As HttpContext = HttpContext.Current Dim page As Page = TryCast(context.Handler, Page) HttpContext.Current.User.Identity.Name.Contains(sKey) page.Session("user") = HttpContext.Current.Session.SessionID ''Session("user") = Txtuserid.Text + Txtpassword.Text ' Let them in - redirect to main page, etc. Response.Redirect("Home.aspx?Uid=" + Txtuserid.Text + "") Else ' cache item exists, so too bad... lblDisplay.Text = "<Marquee><h1><font color=red>Already Logged IN</font></h1></marquee>" Return End If lblDisplay.Text = "Invalid UserName and Password Try Again !!!" End If End While
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)