is anyone willing to help me with session

d2005

Active member
Joined
Aug 31, 2005
Messages
37
Location
ireland
Programming Experience
Beginner
using the session thats created

need to understand how to create and use the session

i have a login and all working but i dont know how to work with it

let me know if ye want something to do and guide me through it
:)
 
Last edited:
if anyone knows then how to display specific info then that would be great.

my webconfig
VB.NET:
	-->
	<authentication mode="Forms" /> 

	-->
	<authorization>
		<deny users="?" /> <!

..........
   <sessionState 
			mode="InProc"
			stateConnectionString="tcpip=127.0.0.1:42424"
			sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
			cookieless="false" 
			timeout="20"

my login page
VB.NET:
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
		If companyDB.ValidateUser(txtUsername.Text, txtPassword.Text) Then
			FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, chkAutomatic.checked)
		Else
			lblError.Visible = True
			lblError.Text = "incorrect username and password, " _
			& " please try again."

		End If

my companydb
VB.NET:
Public Shared Function ValidateUser(ByVal UserName As String, ByVal Password As String) _
			As Boolean
		Dim sSelect As String
		sSelect = "SELECT COUNT(*) FROM tb_comp_detail " _
				& "WHERE companycode = '" & UserName _
				& "' AND comp_password = '" & Password & "'"
		Dim cmdSelect As New SqlCommand(sSelect, Connection)
		Dim iCount As Integer
		cmdSelect.Connection.Open()
		iCount = cmdSelect.ExecuteScalar()
		cmdSelect.Connection.Close()
		If iCount = 0 Then
			Return False
		Else
			Return True
		End If
	End Function

an example of a user control
VB.NET:
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 IsPostBack Then
			If Page.User.Identity.IsAuthenticated Then
				lblheader.Text = "Home Page For - "
				lblheader.text &= Page.User.Identity.Name & "."
			End If
		End If
	End Sub

the question really is
if i have textboxes in the webform,
how can i display data only for the user that is currently logged in,
how do i use the session which is created when they log in, as in the user control.

PLEASE TELL ME IM GOING ABOUT THIS THE RIGHT WAY
 
lol,
i never get the chance to smoke too many cubans though
(one of the best pictures ive ever seen) che
 
a good example of what i need is this

i have a table with company code drivername and driver reg

i have a form with only 2 textboxes,
for drivername and driver reg

companycode is the username that was used to log in

i want to write to the database

the logged in user to companycode(automatic)
then the details they entered to drivername and driver reg

the code i have is as below - NB tester was just to check it was working




HTML:
Dim sqlcompDrivers As New SqlCommand("INSERT INTO tb_comp_drivers(companycode,driver_fname,Registration) VALUES('tester','" & txtDriverName.Text & "','" & txtDriverReg.Text & "');", oSQLConn) oSQLConn.Open() sqlcompDrivers.ExecuteNonQuery() oSQLConn.Close()



this is an example of my needs
 
Using session variables is quite easy. Whatever you want to store in a session variable you would do something like this:

Session("variable_name") = value

Recall them by using this syntax:

Session("variable_name")

For example:

Session("Username") = Textbox1.Text
.... somewhere else...
If Session("Username") = "user" Then
.....


Blokz
 
Back
Top