sessions again
-
HI I am tryin to make a simple session which should pass the verified username accross to the user home page and display the username in a label i have the following Dim uname As String = txtUserName.Text Session("username") = uname and i am tryin to catch it using the following Dim username As String username = Request.QueryString.Get("username") lblUsername.Text = username i have also tried, to no avail username = ctype(session("username"),string) Anyone see a problem boy
-
HI I am tryin to make a simple session which should pass the verified username accross to the user home page and display the username in a label i have the following Dim uname As String = txtUserName.Text Session("username") = uname and i am tryin to catch it using the following Dim username As String username = Request.QueryString.Get("username") lblUsername.Text = username i have also tried, to no avail username = ctype(session("username"),string) Anyone see a problem boy
//Dim uname As String = txtUserName.Text //Session("username") = uname Check the uname is empty or not. i think you are trying to use the querystring value to set it in username. so check whether the username is empty or not. //Dim username As String //username = Request.QueryString.Get("username") //lblUsername.Text = username IF everything is ok ,then it will surely work.
All The Best Sathesh Pandian
-
HI I am tryin to make a simple session which should pass the verified username accross to the user home page and display the username in a label i have the following Dim uname As String = txtUserName.Text Session("username") = uname and i am tryin to catch it using the following Dim username As String username = Request.QueryString.Get("username") lblUsername.Text = username i have also tried, to no avail username = ctype(session("username"),string) Anyone see a problem boy
username = Request.QueryString.Get("username")
username = Session("username").ToString()
-
username = Request.QueryString.Get("username")
username = Session("username").ToString()
-
HI I am tryin to make a simple session which should pass the verified username accross to the user home page and display the username in a label i have the following Dim uname As String = txtUserName.Text Session("username") = uname and i am tryin to catch it using the following Dim username As String username = Request.QueryString.Get("username") lblUsername.Text = username i have also tried, to no avail username = ctype(session("username"),string) Anyone see a problem boy
You can do a simple test like so: On a test page, in the form load event (or some other event): Session("username") = "Testing" Then on any other page in your site, you can do the following. If Not Session("username") Is Nothing Then Response.Write(Session("username").ToString()) End If Because Sessions are objects like most things, you can simply call the ToString() method on the session object, as you know that what you are saving is a string already. I would'nt waist the overhead doing a conversion. If you still do not get the value from the session object, make sure that sessions are enabled either by your host and/or in your web.config. Hope this helps
-
You can do a simple test like so: On a test page, in the form load event (or some other event): Session("username") = "Testing" Then on any other page in your site, you can do the following. If Not Session("username") Is Nothing Then Response.Write(Session("username").ToString()) End If Because Sessions are objects like most things, you can simply call the ToString() method on the session object, as you know that what you are saving is a string already. I would'nt waist the overhead doing a conversion. If you still do not get the value from the session object, make sure that sessions are enabled either by your host and/or in your web.config. Hope this helps
Hi Guys I just can't get this stupid session to work I have tried doin in a seperate method and callin that method from the page_load to no avail once i log in and set the session variable, it jus goes to the next page and does nothin at all, i have even tried returnin the value in a textbox on the second page and i get nothin. I get value for the session after i set it, so there must be somthin wrong with my page when it is receivin it any ideas
I set my session variable equal to the users username once it has been validated as being a valid login Sub validateLogin(ByVal cmdString) 'Creates object and sets value equal to return value Dim validation As Object = cmdString.Parameters("?p_valid").Value 'Validates if users login is valid or invalid If validation = 0 Then Label1.Text = ("Your Login is not valid") Else Dim uname As String = txtUserName.Text Session("Loggedin") = "Yes" Session("username") = uname MsgBox(Session("username").ToString) checkGroupStatus() End If End Sub What i want to do is place this value in a label and it jus does nothin I have it set to a messagebox in this example any help would be appreciated cheers boyindie <%@ Page Language="VB" AutoEventWireup="false" CodeFile="adminHome.aspx.vb" Inherits="adminHome" Strict="true" %> Sub page_load() MsgBox("username is:" & Session("username").ToString) End Sub Untitled Page Welcome * [Users](adminUserAccounts.aspx) * Site Maintenance * Content Manager
-
Hi Guys I just can't get this stupid session to work I have tried doin in a seperate method and callin that method from the page_load to no avail once i log in and set the session variable, it jus goes to the next page and does nothin at all, i have even tried returnin the value in a textbox on the second page and i get nothin. I get value for the session after i set it, so there must be somthin wrong with my page when it is receivin it any ideas
I set my session variable equal to the users username once it has been validated as being a valid login Sub validateLogin(ByVal cmdString) 'Creates object and sets value equal to return value Dim validation As Object = cmdString.Parameters("?p_valid").Value 'Validates if users login is valid or invalid If validation = 0 Then Label1.Text = ("Your Login is not valid") Else Dim uname As String = txtUserName.Text Session("Loggedin") = "Yes" Session("username") = uname MsgBox(Session("username").ToString) checkGroupStatus() End If End Sub What i want to do is place this value in a label and it jus does nothin I have it set to a messagebox in this example any help would be appreciated cheers boyindie <%@ Page Language="VB" AutoEventWireup="false" CodeFile="adminHome.aspx.vb" Inherits="adminHome" Strict="true" %> Sub page_load() MsgBox("username is:" & Session("username").ToString) End Sub Untitled Page Welcome * [Users](adminUserAccounts.aspx) * Site Maintenance * Content Manager
Did you try adding a test value like I described. Then you could step through it line by line checking if the condition(s) are met. If Not Session("username") Is Nothing Then Response.Write(Session("username").ToString()) End If If set a break point on the "If.." you would see if the session variable is "something" and if so, obtain its value. Are you sure that this will ever equal true: If Validation Then This variable is just a raw object, not of boolean type. Maybe you should look at that as well. Dim validation As Object = cmdString.Parameters("?p_valid").Value Dim validation As Boolean = Boolean.TryParse(cmdString.Parameters("?p_valid").Value, False)
-
HI I am tryin to make a simple session which should pass the verified username accross to the user home page and display the username in a label i have the following Dim uname As String = txtUserName.Text Session("username") = uname and i am tryin to catch it using the following Dim username As String username = Request.QueryString.Get("username") lblUsername.Text = username i have also tried, to no avail username = ctype(session("username"),string) Anyone see a problem boy
Dim uname As String = txtUserName.Text Session("username") = uname and i am tryin to catch it using the following Dim username As String username = Request.QueryString.Get("username") lblUsername.Text = username hey are youo want the value of the session variable .. if yes then u do not use QueryString Method u have to use like /// Dim username As String username = Session("username").ToString(); lblUsername.Text = username
-
Did you try adding a test value like I described. Then you could step through it line by line checking if the condition(s) are met. If Not Session("username") Is Nothing Then Response.Write(Session("username").ToString()) End If If set a break point on the "If.." you would see if the session variable is "something" and if so, obtain its value. Are you sure that this will ever equal true: If Validation Then This variable is just a raw object, not of boolean type. Maybe you should look at that as well. Dim validation As Object = cmdString.Parameters("?p_valid").Value Dim validation As Boolean = Boolean.TryParse(cmdString.Parameters("?p_valid").Value, False)
It never seems to ever reach the code I tried doing what you said above and it jus does all the page setup but it never runs the code for some annoyin reason, I have placed the code in the page_load the validation method does work properly, its not a boolean it returns and int, if it is 1 then it sets the users login session to true and takes the users username and passes that into a session. it should then go and check the users privelages and redirect them to the correct home page could my login session effect my username session being passed? Any ideas Cheers Jack
-
Dim uname As String = txtUserName.Text Session("username") = uname and i am tryin to catch it using the following Dim username As String username = Request.QueryString.Get("username") lblUsername.Text = username hey are youo want the value of the session variable .. if yes then u do not use QueryString Method u have to use like /// Dim username As String username = Session("username").ToString(); lblUsername.Text = username