| core_net

# example
    1     <?php
    2     # include the configuration file.
    3     require_once($_SERVER['DOCUMENT_ROOT'] . '../global.conf.php');
    4     require_once($APP['path']['core'] . 'net/http/session/Bs_SimpleSession.class.php');
    5
    6       ################################################################################
    7       # Start of the session
    8       $session =& $GLOBALS['Bs_SimpleSession']; // Use the per ref operator '=&' <-- !!
    9
    10      ################################################################################
    11      # Sample 2
    12      # --------
    13      # A *parallel* sessions called 'bigDataSession'
    14      # Chage some properties
    15      $prop = array (
    16         'path'           => 'c:/',
    17         'maxStandbyTime' => 1, // <- How long should the session stay valid (in min) if not used. 0 means until browser end.
    18         'maxLifeTime'    => 3  // <- Independent of use, invalidat after this time (im min).  0 means until browser end.
    19        );
    20      $ok = $session->setProperty($prop, 'bigDataSession');   // <----- Optional. Set property here if needed
    21      if (!$ok) XR_dump($session->getErrors(), __LINE__, '', __FILE__);
    22
    23        $output = '';
    24      $output .= "Setting Session Property to ";
    25      $output .= "maxLifetime: {$prop['maxLifeTime']}min, maxStandbyTime: {$prop['maxStandbyTime']}min\n";
    26      $output .= "<hr>";
    27      //$session->unregister('my_var', 'bigDataSession');
    28      $bigVar = '';
    29
    30      if (!$session->isRegistered('my_var', 'bigDataSession')) {
    31        $output .= "<span style='color: Red; font-weight: bold;'>- SESSION TIMED OUT ! - </span><br>\n";
    32      } else {
    33        $output .= "<span style='color: Green; font-weight: bold;'> SESSION Running !</span><br>\n";
    34      }
    35      $ok = $session->register('my_var', $bigVar, 'bigDataSession');
    36      for ($i=0; $i<1000; $i++) {
    37        $bigVar .= '0123456789';
    38      }
    39      if (!$ok) XR_dump($session->getErrors(), __LINE__, '', __FILE__);
    40      $output .= "A Parallel Session with big data : <B> " . strLen($bigVar) / 1000 . " kByte  </B><br>";
    41    ?>
    42    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    43
    44    <html>
    45    <head>
    46    	<title>Example 2 of Bs_SimpleSession</title>
    47    </head>
    48
    49    <body>
    50    <H2>Bs_SimpleSession Sample 2</H2>
    51
    52    <hr>
    53    <?php
    54      echo $output;
    55    ?>
    56    <br><br>
    57
    58    <a href="#" onClick="javascript:var block=document.getElementById('sessProps'); block.style.visibility='hidden'">Hide Session Properties</a>
    59    <div id="sessProps" style="visibility : visible;">
    60    <a name="x" href="x"></a>
    61    <?php
    62      echo $session->toHtml('bigDataSession');
    63    ?>
    64    </div>
    65
    66    </body>
    67    </html>
Documentation generated on Mon, 29 Dec 2003 21:12:42 +0100 by phpDocumentor 1.2.3