javascript + cookies

Discussion in 'Javascript' started by Magnus, Aug 8, 2004.

  1. Magnus

    Magnus Guest

    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
     
    Magnus, Aug 8, 2004
    #1
    1. Advertisements

  2. Magnus

    Moist Guest

    "Magnus" <> a écrit dans le message de
    news:41158dcd$...
    > 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
    >


    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
     
    Moist, Aug 8, 2004
    #2
    1. Advertisements

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

    Magnus wrote:

    > 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
     
    Greg Griffiths, Aug 8, 2004
    #3
  4. Magnus

    Magnus Guest

    "Moist" <> skrev i melding
    news:VXoRc.2722$...
    >
    > "Magnus" <> a écrit dans le message de
    > news:41158dcd$...
    > > 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
    > >

    >
    > 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
    >
    >


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

    - Magnus
     
    Magnus, Aug 9, 2004
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Nitulescu

    Response.Cookies vs Request.Cookies

    Alex Nitulescu, Feb 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    9,441
    Hans Kesting
    Feb 3, 2005
  2. Andy Fish
    Replies:
    3
    Views:
    6,877
    Fredrik Lindner
    Nov 6, 2003
  3. user
    Replies:
    3
    Views:
    856
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Mar 31, 2007
  4. archana
    Replies:
    1
    Views:
    650
  5. mhshpk
    Replies:
    0
    Views:
    781
    mhshpk
    Jul 18, 2007
  6. Eric
    Replies:
    1
    Views:
    2,368
    Mark Fitzpatrick
    Dec 28, 2007
  7. _Who
    Replies:
    7
    Views:
    3,164
  8. Cal Who

    Response.cookies vs Request.cookies

    Cal Who, Dec 5, 2009, in forum: ASP .Net
    Replies:
    7
    Views:
    1,846
    Gregory A. Beamer
    Dec 10, 2009
Loading...