Jump to content

[SOLVED] Can anyone tell me whey this demo pgm will not work?


Phrank

Recommended Posts

When I run it and it always tells me it is a new session. I hit the refresh button but it is always a new session.

 

-----------------------------------------------------------------------------------

 

<?php

  // Initialize a session. This call either creates

  // a new session or re-establishes an existing one.

  session_start(  );

 

  // If this is a new session, then the variable

  // $count will not be registered

  if (!session_is_registered("count"))

  { echo "<br>This is a new session<br>";

    session_register("count");

    session_register("start");

 

    $count = 0;

    $start = time(  );

  }

  else

  {

    $count++;

  }

 

  $sessionId = session_id(  );

 

?>

<!DOCTYPE HTML PUBLIC

  "-//W3C//DTD HTML 4.0 Transitional//EN"

  "http://www.w3.org/TR/html4/loose.dtd" >

<html>

  <head><title>Sessions</title></head>

  <body>

    <p>This page points at a session

        (<?php echo "session ID = " . $sessionId; ?>)

    <br>count = <?php echo $count; ?>.

    <br>start = <?php echo $start; ?>.

    <p>This session has lasted

      <?php

        $duration = time(  ) - $start;

echo "$duration";

      ?>

      seconds.

  </body>

</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.