Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. sessions again

sessions again

Scheduled Pinned Locked Moved ASP.NET
help
10 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    boyindie
    wrote on last edited by
    #1

    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

    S M D D 4 Replies Last reply
    0
    • B boyindie

      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

      S Offline
      S Offline
      sathesh pandian
      wrote on last edited by
      #2

      //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

      1 Reply Last reply
      0
      • B boyindie

        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

        M Offline
        M Offline
        Manas Bhardwaj
        wrote on last edited by
        #3

        username = Request.QueryString.Get("username")

        username = Session("username").ToString()
        
        B 1 Reply Last reply
        0
        • M Manas Bhardwaj

          username = Request.QueryString.Get("username")

          username = Session("username").ToString()
          
          B Offline
          B Offline
          boyindie
          wrote on last edited by
          #4

          still no joy:(

          1 Reply Last reply
          0
          • B boyindie

            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

            D Offline
            D Offline
            doWhileSomething
            wrote on last edited by
            #5

            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

            My Personal Site

            B 1 Reply Last reply
            0
            • D doWhileSomething

              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

              My Personal Site

              B Offline
              B Offline
              boyindie
              wrote on last edited by
              #6

              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

              D 1 Reply Last reply
              0
              • B boyindie

                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

                D Offline
                D Offline
                doWhileSomething
                wrote on last edited by
                #7

                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)

                My Personal Site

                B 1 Reply Last reply
                0
                • B boyindie

                  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

                  D Offline
                  D Offline
                  Deepak Gedia
                  wrote on last edited by
                  #8

                  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

                  B 1 Reply Last reply
                  0
                  • D doWhileSomething

                    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)

                    My Personal Site

                    B Offline
                    B Offline
                    boyindie
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    • D Deepak Gedia

                      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

                      B Offline
                      B Offline
                      boyindie
                      wrote on last edited by
                      #10

                      Problem sorted wasn't importing system.data :doh:

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups