Results 1 to 6 of 6

Thread: Session object

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Posts
    8

    Post Session object

    I'm having this problem of passing session object. When i move from one hyperlink to another, my session object becomes empty.
    say:
    in page1.aspx
    Session("isValid") = True

    and when i clicked on the hyperlink
    <a href=page2.aspx></a>

    it still goes to page2 but I can't get the value of Session("isValid"), when i try to trace it, it is empty.

    I've tried using response.redirect, but still the same prob.

    so, how can i pass session around the pages?


  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    In your web.config file, there should be a tag with an attribute that lets you turn on/off session state management. Make sure this switch isn't set to false.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Posts
    8
    I've check, It is on....
    I'm totally confused....

  4. #4
    Member Ooogaleee's Avatar
    Join Date
    Nov 2002
    Location
    Jacksonville, FL
    Posts
    52
    post your code if you don't mind...i too have been working with session objects recently and have had good luck passing and retaining values...

    Ooogs

  5. #5
    Lively Member
    Join Date
    Nov 2002
    Location
    Hong Kong
    Posts
    83
    Try to use relative path e.g. ./ and ../

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Posts
    8
    I started with the login page where user enter password and id, this is how i set the session object if the user exist.

    Dim objComm As New SqlCommand(strSQL, objConn) ' Reserve space in memory 'for the SqlCommand object
    Dim objReader As SqlDataReader
    Try
    objConn.Open()
    objReader = objComm.ExecuteReader()
    If objReader.Read() = False Then
    Session("Invalid") = "True"
    Return False

    Else
    Session("Invalid") = ""
    Session("LoggedIn") = "True"
    Session("UserID") = objReader.Item("UserID").ToString
    Session("Category") = objReader.Item("Mem_Category").ToString
    Return True
    End If
    Finally
    End Try
    objReader.Close()
    objConn.Close()

    Then, i transfer the user to different page according to their member category by using server.transfer.

    server.transfer("Member.aspx")

    in Member.aspx page, I still manage to retrieve all info in the Session object, including session("userID").

    but when i clicked on a hyperlink that link to another page, it show error that object reference not set to an instance of object in this line of code

    " dim str
    str= session("UserID")"

    btw, the hyperlink is inside a user control, does it matter?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width