PHP/Cookie Session/session destroy

Материал из Web эксперт
Перейти к: навигация, поиск

Destroying a session

   <source lang="html4strict">

<?php session_start( ); $_SESSION["username"] = "Michele"; session_destroy( ); echo "At this point we can still see the value of username as "; echo $_SESSION["username"]."
"; unset ($_SESSION["username"); if (is_null($_SESSION["username"])) {

   echo "Now the value of username is (blank)";

} ?>

 </source>
   
  


Ending a Session

   <source lang="html4strict">

<?

   session_start( );
   $_SESSION = array( );
   session_destroy( );

?>

 </source>
   
  


function session_destroy() ends all persistent data corresponding to the current user session.

   <source lang="html4strict">

Its syntax is: boolean session_destroy() <? session_start(); // do some session stuff session_destroy(); ?>

 </source>