javascript + cookies

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

    javascript + cookies

    I have a iframe inside a main html file. The iframe is used to display
    various html files. Inside the html files displayed in the iframe I want to
    have javascript to set certain global cookies, which I can later access in
    the main html file. Is this possible? It seems like when the cookies are set
    inside the iframe, the cookies are not accessible in the main html file. I
    have also tried using:

    document.cookie = "path=/;var=val"

    Also with no luck.

    Anyone have a cure for this?

    - Magnus


  • Moist

    #2
    Re: javascript + cookies


    "Magnus" <no@spam.com> a écrit dans le message de
    news:41158dcd$1 @news.broadpark .no...[color=blue]
    > I have a iframe inside a main html file. The iframe is used to display
    > various html files. Inside the html files displayed in the iframe I want[/color]
    to[color=blue]
    > have javascript to set certain global cookies, which I can later access in
    > the main html file. Is this possible? It seems like when the cookies are[/color]
    set[color=blue]
    > inside the iframe, the cookies are not accessible in the main html file. I
    > have also tried using:
    >
    > document.cookie = "path=/;var=val"
    >
    > Also with no luck.
    >
    > Anyone have a cure for this?
    >
    > - Magnus
    >[/color]

    One possible cure:
    If, once you are done with the iframe, you go back to the main html, global
    array or variables could be used instead to hold your data. If you quit the
    browser then you can save in cookies at then main html level, this data can
    be retrieve at the next invocation of your main html.

    (even though I too would like to know how to access cookies globaly)
    Moist


    Comment

    • Greg Griffiths

      #3
      Re: javascript + cookies

      You may need to set the DOMAIN attribute of the cookie.

      Magnus wrote:
      [color=blue]
      > I have a iframe inside a main html file. The iframe is used to display
      > various html files. Inside the html files displayed in the iframe I want to
      > have javascript to set certain global cookies, which I can later access in
      > the main html file. Is this possible? It seems like when the cookies are set
      > inside the iframe, the cookies are not accessible in the main html file. I
      > have also tried using:
      >
      > document.cookie = "path=/;var=val"
      >
      > Also with no luck.
      >
      > Anyone have a cure for this?
      >
      > - Magnus[/color]

      Comment

      • Magnus

        #4
        Re: javascript + cookies


        "Moist" <moist@msn.co m> skrev i melding
        news:VXoRc.2722 $Xc5.15616@webe r.videotron.net ...[color=blue]
        >
        > "Magnus" <no@spam.com> a écrit dans le message de
        > news:41158dcd$1 @news.broadpark .no...[color=green]
        > > I have a iframe inside a main html file. The iframe is used to display
        > > various html files. Inside the html files displayed in the iframe I want[/color]
        > to[color=green]
        > > have javascript to set certain global cookies, which I can later access[/color][/color]
        in[color=blue][color=green]
        > > the main html file. Is this possible? It seems like when the cookies are[/color]
        > set[color=green]
        > > inside the iframe, the cookies are not accessible in the main html file.[/color][/color]
        I[color=blue][color=green]
        > > have also tried using:
        > >
        > > document.cookie = "path=/;var=val"
        > >
        > > Also with no luck.
        > >
        > > Anyone have a cure for this?
        > >
        > > - Magnus
        > >[/color]
        >
        > One possible cure:
        > If, once you are done with the iframe, you go back to the main html,[/color]
        global[color=blue]
        > array or variables could be used instead to hold your data. If you quit[/color]
        the[color=blue]
        > browser then you can save in cookies at then main html level, this data[/color]
        can[color=blue]
        > be retrieve at the next invocation of your main html.
        >
        > (even though I too would like to know how to access cookies globaly)
        > Moist
        >
        >[/color]

        Simple solution that works for me is to use parent.document .cookie.

        - Magnus


        Comment

        Working...