downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/intro.session.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/book.session.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'intro.session.php',
   
1 => 'Introduction',
  ),
 
'up' =>
  array (
   
0 => 'book.session.php',
   
1 => 'Session Handling',
  ),
 
'prev' =>
  array (
   
0 => 'book.session.php',
   
1 => 'Sessions',
  ),
 
'next' =>
  array (
   
0 => 'session.setup.php',
   
1 => 'Installing/Configuring',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="intro.session" class="preface">
  <h1 class="title">Introduction</h1>
  <p class="para">
   Session support in PHP consists of a way to preserve certain data
   across subsequent accesses. This enables you to build more
   customized applications and increase the appeal of your web site.
  </p>
  <p class="para">
   A visitor accessing your web site is assigned a unique id, the
   so-called session id. This is either stored in a cookie on the
   user side or is propagated in the URL.
  </p>
  <p class="para">
   The session support allows you to register arbitrary numbers of
   variables to be preserved across requests. When a visitor accesses
   your site, PHP will check automatically (if <a href="session.configuration.php#ini.session.auto-start" class="link">session.auto_start</a>
   is set to 1) or on your request (explicitly through
   <a href="function.session-start.php" class="function">session_start()</a> or implicitly through
   <a href="function.session-register.php" class="function">session_register()</a>) whether a specific session
   id has been sent with the request. If this is the case, the prior
   saved environment is recreated.
  </p>
  <div class="caution"><b class="caution">Caution</b>
   <p class="para">
    If you turn on <a href="session.configuration.php#ini.session.auto-start" class="link">
    session.auto_start</a> then the only way to put objects
    into your sessions is to load its class definition using
    <a href="ini.core.php#ini.auto-prepend-file" class="link">auto_prepend_file</a>
    in which you load the class definition else you will have to
    <a href="function.serialize.php" class="function">serialize()</a> your object
    and <a href="function.unserialize.php" class="function">unserialize()</a> it 
    afterwards.
   </p>
  </div>
  <p class="para">
   All registered variables are serialized after the request
   finishes.  Registered variables which are undefined are marked as
   being not defined.  On subsequent accesses, these are not defined
   by the session module unless the user defines them later.
  </p>
  <div class="warning"><b class="warning">Warning</b>
   <p class="para">
    Some types of data can not be serialized thus stored in sessions. It
    includes <a href="language.types.resource.php" class="type resource">resource</a> variables or objects with circular
    references (i.e. objects which passes a reference to itself to another
    object).
   </p>
  </div>
  <blockquote><p><b class="note">Note</b>:
  
    Session handling was added in PHP 4.0.0.
   <br />
  </p></blockquote>
  <blockquote><p><b class="note">Note</b>:
  
    Please note when working with sessions that a record of a session
    is not created until a variable has been registered using the
    <a href="function.session-register.php" class="function">session_register()</a> function or by adding a new
    key to the <var class="varname"><a href="reserved.variables.session.php" class="classname">$_SESSION</a></var> superglobal array. This
    holds true regardless of if a session has been started using the
    <a href="function.session-start.php" class="function">session_start()</a> function.
   <br />
  </p></blockquote>
  <blockquote><p><b class="note">Note</b>:
  
    PHP 5.2.2 introduced an undocumented feature to store session files
    in &quot;/tmp&quot; even if <a href="ini.sect.safe-mode.php#ini.open-basedir" class="link">open_basedir</a>
    was enabled and &quot;/tmp&quot; is not explicitly added to the allowed paths
    list. This feature has been removed from PHP as of PHP 5.3.0.
   <br />
  </p></blockquote>
 </div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites