Sessions

    Date: 01/17/09 (PHP Community)    Keywords: browser

    Hi Guys!

    Another one of my dumb questions! This time, it's about sessions.

    What's the best way to make a session reset itself when you hit the refresh button?


      if (!session_start())
      {
        session_start();
        header("Cache-control: private");
        $_SESSION['num'] = 0;
        $i = $_SESSION['num'];
        echo $i;
      }
      else
      {
        $i = $_SESSION['num'];
        echo $i;
      }
      
      if (!$i)
        $i = 0;
    

    (please ignore the echo's. They're what I've been using to track what the numbers are while I make this project)

    Right now, that's what I've got controlling my session for this particular thing. What happens is the value in $_SESSION['num'] increases every time the "add another item" link is clicked. A new set of fields pops up at the bottom of the form and it's filloutable. When you don't have any more things to add, you hit the submit button.

    But say I end up refreshing the page halfway through because I want to restart? Then the number doesn't reset back to 0.

    What's the best way to reset it back to zero on refresh or on the reloading of a page (without closing the browser)

    Thanks!


    Source: http://community.livejournal.com/php/654764.html

« php driven image gallery -... || Working with multi arrays »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home