SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2000
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cookie and Iframe

    Hi all,

    I have this problem, the cookie value doesn't get updated for 2 different iframes within a page. I understand from php.net that the cookie value won't be visible until the next page. But 2 iframes essentially are two pages. The html page shows two iframes with the same counter incremented all the time (NULL-NULL, 1-1, 2-2, 3-3....). The question is how to make the first iframe update the cookie, then the second iframe uses this updated value (meaning NULL-1, 2-3, 4-5....)

    in test_cookie.php

    PHP Code:
    <?php
    var_dump
    ($_COOKIE['test']);
    SetCookie('test',$_COOKIE['test']+1,time()+86400);
    ?>
    in test_cookie.html

    Code:
    <iframe src="test_cookie.php"></iframe> 
    <iframe src="test_cookie.php"></iframe>

    Thanks to who can solve this problem

  2. #2
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Raleigh, NC
    Posts
    783
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm sure you could find some javascript hack but really, that's just not how html and cookies work

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2000
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why would you say it's not how html/cookie work? For which purposes are they designed for then?

  4. #4
    SitePoint Addict psyon's Avatar
    Join Date
    May 2004
    Location
    Cedar Rapids
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You sure the browser isnt caching test_cookie.php's output, and thus not visiting it a 2nd time?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •