sessions in javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gaya3
    New Member
    • Aug 2007
    • 184

    #1

    sessions in javascript

    hi,
    Any one please say me how to assign javascript variable for session variable in javascript..
    Thanks in Advance

    -Thanks & Regards,
    Hamsa
  • prometheuzz
    Recognized Expert New Member
    • Apr 2007
    • 197

    #2
    Hi, I've moved your post from the Java forum to the (amongst others) JavaScript forum: the two do sound the same, but are in fact two different languages.

    Comment

    • gaya3
      New Member
      • Aug 2007
      • 184

      #3
      session in javascript

      HI all,
      Any one pl say how to assign javascript variable value for session variable
      in JS.
      something like..
      <script>
      <% pagesession.set Attribute("samp le",document.my form.input1.val ue)%>
      </script>
      Thanks in Advance

      -Hamsa

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        Originally posted by gaya3
        HI all,
        Any one pl say how to assign javascript variable value for session variable
        in JS.
        something like..
        <script>
        <% pagesession.set Attribute("samp le",document.my form.input1.val ue)%>
        </script>
        Thanks in Advance

        -Hamsa
        OK.
        Let me explain.
        JS executes in Client Side and the session is in Server Side.
        Now if you want to assign the Javascript Variable into the session then simply pass that Variable and access it through request.getPara meter() and assign it.
        Ok.
        I think you got my point and best of luck with your try.

        Kind regards,
        Dmjpro.

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by dmjpro
          OK.
          Let me explain.
          JS executes in Client Side and the session is in Server Side.
          Now if you want to assign the Javascript Variable into the session then simply pass that Variable and access it through request.getPara meter() and assign it.
          Ok.
          I think you got my point and best of luck with your try.

          Kind regards,
          Dmjpro.
          Actually the request.getPara meter methods are used in JSPs to get form fields. To get values in the session you use session.getAttr ibute

          Comment

          • basha9
            New Member
            • Aug 2007
            • 4

            #6
            Hello everybody,

            can u plz tell me is there any option in javascript to keep values in session and retrive values from session.

            Comment

            • dmjpro
              Top Contributor
              • Jan 2007
              • 2476

              #7
              Originally posted by basha9
              Hello everybody,

              can u plz tell me is there any option in javascript to keep values in session and retrive values from session.
              Welcome to TSDN.
              Look the JavaScript runs on client side and session runs on server side.
              So doing something with session in JavaScript it does not make any sense.

              Kind regards,
              Dmjpro.

              Comment

              • dmjpro
                Top Contributor
                • Jan 2007
                • 2476

                #8
                Originally posted by r035198x
                Actually the request.getPara meter methods are used in JSPs to get form fields. To get values in the session you use session.getAttr ibute
                You are right r035198x but he is intending to store JavaScript Variable into the session then he has to get is first using request.getePar ameter() then store it using session.setAttr ibute().

                Kind regards,
                Dmjpro.

                Comment

                • dmjpro
                  Top Contributor
                  • Jan 2007
                  • 2476

                  #9
                  Originally posted by gaya3
                  HI all,
                  Any one pl say how to assign javascript variable value for session variable
                  in JS.
                  something like..
                  <script>
                  <% pagesession.set Attribute("samp le",document.my form.input1.val ue)%>
                  </script>
                  Thanks in Advance

                  -Hamsa
                  Ok look at this example given below.

                  [code=html]
                  <input type=hidden value = "text_value " name = test_fld>
                  [/code]

                  [code=jsp]
                  String s = request.getPara meter("test_fld ");
                  session.setAttr ibute("test_att r",s);
                  [/code]

                  I think now it is clear to you.
                  When you submit the page then test_fld ll pass to the action page then you ll get that value using request.getPara meter().

                  OK.

                  Kind regards,
                  Dmjpro.

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Originally posted by gaya3
                    HI all,
                    Any one pl say how to assign javascript variable value for session variable
                    in JS.
                    something like..
                    <script>
                    <% pagesession.set Attribute("samp le",document.my form.input1.val ue)%>
                    </script>
                    Thanks in Advance

                    -Hamsa
                    If you want a pure Javascript solution, use cookies.

                    Comment

                    • dmjpro
                      Top Contributor
                      • Jan 2007
                      • 2476

                      #11
                      Originally posted by acoder
                      If you want a pure Javascript solution, use cookies.
                      Yup Acoder is right you can use Cookie..... this is both side ....Server Side and also Client Side.
                      The cookie is nothing but a small piece of informations which is exchanged across Server and Client.
                      And read about details on the link provided by Acoder.

                      Kind regards,
                      Dmjpro.

                      Comment

                      Working...