Set session variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DS

    Set session variables

    In client-side script (<script> codes </script>), how can set / get session
    variables' values? Pls advise.

    DS


  • Bhaskardeep Khaund

    #2
    Re: Set session variables

    Hi,

    If your are using JavaScript, you can assign the value for ur ASP session variable into a JavaScript variable and then work on it.
    Like

    <script>
    var name;
    name = "<%=Session("na me")%>"
    ........

    </script>

    Bhaskardeep Khaund

    Comment

    • DS

      #3
      Re: Set session variables

      But, how can I assign a variable or values to a session variable within a client-side script? For example

      <script>
      //Java script
      document.write ("<%Session("It emCode") = " + strTest + "%>")
      </script>
      Any wrongs here?

      DS
      "Bhaskardee p Khaund" <bhaskar_999@ho tmail.com> 在郵件 news:OliKG6ZuDH A.2448@TK2MSFTN GP12.phx.gbl 中撰寫...
      Hi,

      If your are using JavaScript, you can assign the value for ur ASP session variable into a JavaScript variable and then work on it.
      Like

      <script>
      var name;
      name = "<%=Session("na me")%>"
      .......

      </script>

      Bhaskardeep Khaund

      Comment

      • Bhaskardeep Khaund

        #4
        Re: Set session variables

        Hi,

        How can you assign a Session variable to a client-side variable. Since, session would be executed on the server-side and your JS scripts would be executed on the clients computer. I think u cant do that.

        Bhaksardeep Khaund

        Comment

        • DS

          #5
          Re: Set session variables

          Then, how can I pass a value, which is got in client-side, to server-side? Can I call a client-side function, which returns a value, in server-side script? Actually, I am in trouble on how to communicate between client and server sides script very well....please advise.

          Thanks,
          DS
          "Bhaskardee p Khaund" <bhaskar_999@ho tmail.com> 在郵件 news:eQo67%23ku DHA.3224@tk2msf tngp13.phx.gbl 中撰寫...
          Hi,

          How can you assign a Session variable to a client-side variable. Since, session would be executed on the server-side and your JS scripts would be executed on the clients computer. I think u cant do that.

          Bhaksardeep Khaund

          Comment

          • Bob Barrows

            #6
            Re: Set session variables

            DS wrote:[color=blue]
            > In client-side script (<script> codes </script>), how can set / get
            > session variables' values? Pls advise.
            >
            > DS[/color]

            There was a technique posted sometime in the last couple weeks for setting a
            session variable via an IMG tag on the page. I'll see if I can find it
            later.

            In the meantime, you can also use XMLHTTP to pass a value to a server-side
            page which can then set a session variable. A Google search, or a visit to
            www.aspfaq.com, should provide you with a few examples.


            To pass a session variable's value to client-side script, simply
            response.write it:

            client_side_var = "<%=session("va r")%>"

            HTH,
            Bob Barrows

            --
            Microsoft MVP - ASP/ASP.NET
            Please reply to the newsgroup. This email account is my spam trap so I
            don't check it very often. If you must reply off-line, then remove the
            "NO SPAM"


            Comment

            Working...