Results 1 to 2 of 2

Thread: how to count page refresh with sessions?

  1. #1
    Join Date
    Mar 2007
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy how to count page refresh with sessions?

    hi i am stuck with a problem frm last few days n not gettin a solution.
    it seems u can count the number of time a page is refreshed using session and session variables. i.e if i want my page to be refreshed 10 times then i can hv a session variable whose val is set to 10 n then keep decreasing it whn the page is refreshed.whn the val reaches 0 the page can be redirected to another page.is this possible.if yes how to do it?
    help wil be appreciated.
    thanks

  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Try this:
    PHP Code:
    <?php
    session_start
    ();
    $mypage 'index.php';
    if (!isset(
    $_SESSION['refresher']))    {
        
    $_SESSION['refresher'] = 10;
    }
    elseif (
    $_SESSION['refresher'] <= 0)    {
        
    $_SESSION['refresher'] = 10;
        
    header("location:$mypage");
    }
    else    {
    $_SESSION['refresher']--;
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="refresh" content="10">
    <title>Refresher</title>
    </head>

    <body>
    <p><?php echo $_SESSION['refresher']+1?> times until redirection.</p>
    </body>
    </html>
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

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
  •