Unable to create a session in asp

Discussion in 'C#' started by anatar02, Sep 17, 2009.

  1. #1
    Hi All,

    I am new for development as well as asp; my problem is session’s creation using (parameter).
    Say for example

    i have form1.asp

    <body>
    Test Suite Email Form:
    <br />
    <form method="get" action="simpleform.asp">
    First Name: <input type="text" name="fname" /><br />
    Last Name: <input type="text" name="lname" /><br /><br />
    <input type="submit" value="Submit" />
    </form>

    form2.asp

    <%
    request.querystring("fname")
    Session("fname")=fname
    Session.Timeout = 100
    Response.Write(Session("fname"))%>

    and

    The below set of code is working fine because i am hard coding the values

    <%

    Session("fname")="I am Working"
    Session.Timeout = 100
    Response.Write(Session("fname"))%>


    so could you please help me on this....

    Thanks in advance

    Ashok N
     
    anatar02, Sep 17, 2009 IP
  2. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    You are not assigning the value from the querystring to a variable.
    
    <%
    Dim strFName
    strFName = Request.QueryString("fname")
    Session("fname") = strFName
    Session.Timeout = 100
    Response.Write(Session("fname"))
    %>
    
    Code (markup):
    Assuming you are using classic asp the above should work...
    alternatively:
    
    <%
    Session("fname") = Request.QueryString("fname")
    Session.Timeout = 100
    Response.Write(Session("fname"))%>
    
    Code (markup):
     
    camjohnson95, Sep 18, 2009 IP
  3. Nytrolix

    Nytrolix Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah your not putting fname into a variable.

    As it stands:

    this line here isnt setting fname to a variable, it should be
    request.querystring("fname")

    fname = request.querystring("fname")


    then you put it into your sesison here.
    Session("fname")=fname
     
    Nytrolix, Sep 21, 2009 IP
  4. leebari

    leebari Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ASP session doesn't work well on Internet Explorer 7. I would recommend to look for an alternative solution (ASP class) to handle sessions properly.
     
    leebari, Oct 16, 2009 IP
  5. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #5
    I have used asp session's a lot and have never had a problem with it, whether it is with IE7 (which I use by default) or any other browser.... It is fairly obvious that the problem is with the code.
     
    camjohnson95, Oct 19, 2009 IP
  6. urstop

    urstop Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Sessions work fine with all popular browsers. If it does not work it could be because of your security restrictions set on the cookies by your browser. The browser should be set to accept cookies for the sessions to work.
     
    urstop, Oct 22, 2009 IP
  7. Corwin

    Corwin Well-Known Member

    Messages:
    2,438
    Likes Received:
    107
    Best Answers:
    0
    Trophy Points:
    195
    #7
    Correct, if cookies are disabled, you can't set session variables, they will behave like regular variables (when the page is finished, the variable is cleared).
     
    Corwin, Oct 28, 2009 IP