Set cookie in javascript and retrieve it in vbscript ??

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

    #1

    Set cookie in javascript and retrieve it in vbscript ??

    hi folks,

    just wonder if this is possible or is there a better way of doing
    this. i need to store values in cookies between two forms. the details
    are added in a popup when this is closed the main form stores these
    values in hidden fields. at this point xml is built up and submitted
    to a biztalk server. if there is an error the page is refreshed and
    the initial values i added via the popup are lost.

    my idea was to store these as cookies and populate the main form that
    way if there is an error. My popup uses the following to send details
    back to main form. e.g.,
    window.opener.d ocument.all.Doo rs.value=form1. Doors.value;

    i have only ever used the following to set cookies in vbscript
    <input type="hidden" value="<%=Reque st.Cookies("Doo rs")%>"
    name="Doors" >

    how can i set and get cookies using purely javascript ??? any examples
    greatly appreciated.

    Thanks in advance.

    CG
  • kaeli

    #2
    Re: Set cookie in javascript and retrieve it in vbscript ??

    In article <ee261922.05042 50740.129d70c4@ posting.google. com>, csgraham74
    @hotmail.com enlightened us with...[color=blue]
    > hi folks,
    >
    > just wonder if this is possible or is there a better way of doing
    > this.[/color]

    Best way (IMO) is with session variables, that way if someone has cookies
    turned off or JS turned off, it still works.
    [color=blue]
    >
    > i have only ever used the following to set cookies in vbscript
    > <input type="hidden" value="<%=Reque st.Cookies("Doo rs")%>"
    > name="Doors" >
    >
    > how can i set and get cookies using purely javascript ??? any examples
    > greatly appreciated.[/color]

    Not like this. ;)
    You'd have to set the cookie by calling a function somewhere, probably form
    onsubmit. And you can't call javascript code in a value like you do here with
    ASP.
    There are cookie functions posted here all the time, so a quick Google of the
    group should bring some up. If you can't find any, I have a very simplistic
    cookie function set (check, set, and get, simple values, no domains) in my
    useful section in Kaeli's Space (see my sig).

    --
    --
    ~kaeli~
    The Bermuda Triangle got tired of warm weather. It moved to
    Finland. Now Santa Claus is missing.



    Comment

    • Evertjan.

      #3
      Re: Set cookie in javascript and retrieve it in vbscript ??

      kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
      [color=blue]
      > Best way (IMO) is with session variables, that way if someone has
      > cookies turned off or JS turned off, it still works.
      >[/color]

      Not exactly.
      If session cookies are also turned off,
      every page is a new session,
      without any session variables to start with.

      --
      Evertjan.
      The Netherlands.
      (Replace all crosses with dots in my emailaddress)

      Comment

      • kaeli

        #4
        Re: Set cookie in javascript and retrieve it in vbscript ??

        In article <Xns9643C937F58 91eejj99@194.10 9.133.29>,
        exjxw.hannivoor t@interxnl.net enlightened us with...[color=blue]
        > kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
        >[color=green]
        > > Best way (IMO) is with session variables, that way if someone has
        > > cookies turned off or JS turned off, it still works.
        > >[/color]
        >
        > Not exactly.
        > If session cookies are also turned off,
        > every page is a new session,
        > without any session variables to start with.
        >[/color]

        Most servers I have worked with fall back to URL re-writing if session
        cookies are disabled.
        If yours does not, then you should have all sessions use URL re-writing for
        precisely this reason.

        i.e. from the weblogic docs:
        Using URL Rewriting Instead of Cookies
        In some situations, a browser or wireless device may not accept cookies,
        which makes session tracking with cookies impossible. URL rewriting is a
        solution to this situation that can be substituted automatically when
        WebLogic Server detects that the browser does not accept cookies.

        --
        --
        ~kaeli~
        The secret of the universe is @*&^^^ NO CARRIER



        Comment

        • Evertjan.

          #5
          Re: Set cookie in javascript and retrieve it in vbscript ??

          kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
          [color=blue]
          > In article <Xns9643C937F58 91eejj99@194.10 9.133.29>,
          > exjxw.hannivoor t@interxnl.net enlightened us with...[color=green]
          >> kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
          >>[color=darkred]
          >> > Best way (IMO) is with session variables, that way if someone has
          >> > cookies turned off or JS turned off, it still works.
          >> >[/color]
          >>
          >> Not exactly.
          >> If session cookies are also turned off,
          >> every page is a new session,
          >> without any session variables to start with.
          >>[/color]
          >
          > Most servers I have worked with fall back to URL re-writing if session
          > cookies are disabled.[/color]

          I have no idea what you are talking about.

          Are you talking ASP, Kaeli?
          [color=blue]
          > If yours does not, then you should have all sessions use URL
          > re-writing for precisely this reason.
          >
          > i.e. from the weblogic docs:
          > Using URL Rewriting Instead of Cookies
          > In some situations, a browser or wireless device may not accept
          > cookies, which makes session tracking with cookies impossible. URL
          > rewriting is a solution to this situation that can be substituted
          > automatically when WebLogic Server detects that the browser does not
          > accept cookies.
          >[/color]



          --
          Evertjan.
          The Netherlands.
          (Replace all crosses with dots in my emailaddress)

          Comment

          • kaeli

            #6
            Re: Set cookie in javascript and retrieve it in vbscript ??

            In article <Xns9643CFF8C40 1eejj99@194.109 .133.29>,
            exjxw.hannivoor t@interxnl.net enlightened us with...[color=blue]
            > kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
            >[color=green]
            > > In article <Xns9643C937F58 91eejj99@194.10 9.133.29>,
            > > exjxw.hannivoor t@interxnl.net enlightened us with...[color=darkred]
            > >> kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
            > >>
            > >> > Best way (IMO) is with session variables, that way if someone has
            > >> > cookies turned off or JS turned off, it still works.
            > >> >
            > >>
            > >> Not exactly.
            > >> If session cookies are also turned off,
            > >> every page is a new session,
            > >> without any session variables to start with.
            > >>[/color]
            > >
            > > Most servers I have worked with fall back to URL re-writing if session
            > > cookies are disabled.[/color]
            >
            > I have no idea what you are talking about.[/color]

            Then why did you argue? ;)
            [color=blue]
            >
            > Are you talking ASP, Kaeli?[/color]

            No, actually Weblogic (WSAD) is JSP.
            But ASP (IIS) can do it too. As can Cold Fusion. I don't think Apache /
            Tomcat can auto-detect, but I dunno for sure. I don't think NES (Iplanet)
            can, either, but 6.0 had some nice changes, so maybe it can now.

            Session variables != session cookie.

            Session variables are used (implemented) by a web server, but generally
            implemented by whatever server-side scripting language you're using.
            This has nothing at all to do with javascript unless we're talking JScript
            with .net or some such. The OP said he was open to other ideas, so I gave him
            one.
            For example, in my web app, I store the user's name in a session variable,
            along with several user preferences. These are loaded from the DB when the
            user logs in. They are not stored on the client. The client gets only a
            session ID, which points to that data on the server so I don't have to query
            the DB over and over. Then, I can do something like
            <p>Welcome <%= sessionBean.get UserName() %></p>

            HTH

            --
            --
            ~kaeli~
            I do whatever my Rice Krispies tell me to.



            Comment

            • Evertjan.

              #7
              Re: Set cookie in javascript and retrieve it in vbscript ??

              kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
              [color=blue][color=green]
              >> Are you talking ASP, Kaeli?[/color]
              >
              > No, actually Weblogic (WSAD) is JSP.
              > But ASP (IIS) can do it too. As can Cold Fusion. I don't think Apache
              > / Tomcat can auto-detect, but I dunno for sure. I don't think NES
              > (Iplanet) can, either, but 6.0 had some nice changes, so maybe it can
              > now.
              >
              > Session variables != session cookie.
              >
              > Session variables are used (implemented) by a web server, but
              > generally implemented by whatever server-side scripting language
              > you're using. This has nothing at all to do with javascript unless
              > we're talking JScript with .net or some such. The OP said he was open
              > to other ideas, so I gave him one.
              > For example, in my web app, I store the user's name in a session
              > variable, along with several user preferences. These are loaded from
              > the DB when the user logs in. They are not stored on the client. The
              > client gets only a session ID, which points to that data on the server
              > so I don't have to query the DB over and over. Then, I can do
              > something like <p>Welcome <%= sessionBean.get UserName() %></p>
              >[/color]

              This is neither here nor there, Kaeli.

              If the server does not recognize the client session, the server can store
              al it likes, but does not know which client connection and session the
              stored data belong to.

              So the server either needs a session cookie [a cookie that expires at the
              closing of the browser, also named ram-cookie] or a session code has to be
              sent as a form or query value with all pages.

              Is it the latter you mean.

              --
              Evertjan.
              The Netherlands.
              (Replace all crosses with dots in my emailaddress)

              Comment

              • kaeli

                #8
                Re: Set cookie in javascript and retrieve it in vbscript ??

                In article <Xns9643DB3A717 38eejj99@194.10 9.133.29>,
                exjxw.hannivoor t@interxnl.net enlightened us with...[color=blue]
                >
                > If the server does not recognize the client session, the server can store
                > al it likes, but does not know which client connection and session the
                > stored data belong to.[/color]

                Yes, it does.
                It uses the URL if it can't use cookies. As I said.

                --
                --
                ~kaeli~
                A chicken crossing the road is poultry in motion.



                Comment

                • Evertjan.

                  #9
                  Re: Set cookie in javascript and retrieve it in vbscript ??

                  kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
                  [color=blue]
                  > In article <Xns9643DB3A717 38eejj99@194.10 9.133.29>,
                  > exjxw.hannivoor t@interxnl.net enlightened us with...[color=green]
                  >>
                  >> If the server does not recognize the client session, the server can
                  >> store al it likes, but does not know which client connection and
                  >> session the stored data belong to.[/color]
                  >
                  > Yes, it does.
                  > It uses the URL if it can't use cookies. As I said.[/color]

                  A strange way of describing URL.
                  I would call it the querystring.

                  Anyway, since my users want something from me,
                  I am not going to accomodate them.

                  If they switch off ram-cookies, they loose functionality.

                  If they buy a car,
                  they should know it does not run without petrol,
                  and I am not going to push it.

                  --
                  Evertjan.
                  The Netherlands.
                  (Replace all crosses with dots in my emailaddress)

                  Comment

                  • kaeli

                    #10
                    Re: Set cookie in javascript and retrieve it in vbscript ??

                    In article <Xns9643F32DAB0 23eejj99@194.10 9.133.29>,
                    exjxw.hannivoor t@interxnl.net enlightened us with...[color=blue]
                    > kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
                    >[color=green]
                    > > In article <Xns9643DB3A717 38eejj99@194.10 9.133.29>,
                    > > exjxw.hannivoor t@interxnl.net enlightened us with...[color=darkred]
                    > >>
                    > >> If the server does not recognize the client session, the server can
                    > >> store al it likes, but does not know which client connection and
                    > >> session the stored data belong to.[/color]
                    > >
                    > > Yes, it does.
                    > > It uses the URL if it can't use cookies. As I said.[/color]
                    >
                    > A strange way of describing URL.
                    > I would call it the querystring.
                    >
                    > Anyway, since my users want something from me,
                    > I am not going to accomodate them.
                    >[/color]

                    You don't work on e-commerce and B2B applications, do you?

                    --
                    --
                    ~kaeli~
                    If a chicken and a half can lay an egg and a half in a day
                    and a half, how long would it take for a monkey with a
                    wooden leg to kick the dill seeds out of a pickle?



                    Comment

                    Working...