For other functions in phplib and for the use of other functions related to the session, you can refer to it with the manual or on its website to see the online documentation. It's home in http://phplib.netuse.de/index.PHP3. PHP4 's session implementation is mostly learned from Phplib, and it also relies on cookies to save the session ID and save the variable with the file system (by default). Therefore, its session variable cannot save the object (in fact, it can save the object content, but it has no meaning, because it is stored on disk, not live objects, at best, the body of the object. However, this limitation is not too large, we only need to save the variable in most cases. Of course you can also save the session in the database, and in the next section we'll talk about how to save the session in the database. The session configuration option is also available in the php.ini file because the session support is more than php3 in PHP4. Let's take a look at the roles and meanings of each:
[Session]
Session.save_handler = files; Handler used to Store/retrieve data (save session variables by default, with files)
Session.save_path = c:/temp; Argument passed to Save_handler (the directory where the session variable is saved, under Linux/unix for/TMP, under win for your directory)
; In the case of files, the
; path where data files are stored
Session.use_cookies = 1; Whether to use cookies (whether cookies are used, of course, there is no choice under win)
Session.name = Phpsessid
; Name of the session (the default session uses the cookie name, it is recommended not to change)
; is used as cookie name
Session.auto_start = 0; Initialize session on request startup (if session is automatically enabled, when 1 o'clock, you do not have to call the Session_Start () function on each page)
Session.cookie_lifetime = 0; Lifetime in seconds of cookies (sets the time, in seconds, to save the cookie after it is sent to the browser. The default value is 0, which is indicated until the browser is closed. )
; Or if 0, until browser is restarted
Session.cookie_path =/; The path the cookie is valid for (cookie) (valid path for cookies)
Session.cookie_domain =; The domain the cookie is valid for (a valid domain name for cookies)
Session.serialize_handler = PHP; Handler used to serialize data (defines the identity of the serialized figure, this feature is only used within the WDDX module or PHP. Default value is PHP)
; PHP is the standard serializer of PHP
session.gc_probability = 1; Percentual probability that the (set each temporary file to start processing (GC, garbage collection) processing probabilities. The default value is 1. )
; ' Garbage collection ' process is started
; On every session initialization
Session.gc_maxlifetime = 1440; After this number of seconds, stored (sets the surviving seconds before the temporary file that holds the session is purged)
; Data would be seen as ' garbage ' and
; Cleaned up by the GC process
Session.referer_check =; Check HTTP Referer to invalidate (determines if the session code referenced to the client is to be deleted.) Sometimes when safety or other considerations are taken, the settings are not deleted. The default value is 0. )
; Externally stored URLs containing IDs
session.entropy_length = 0; How many bytes to read from the file (sets the number of bits that the session reads from a high-entropy resource. The default value is 0.)
Session.entropy_file =; Specified here to create the session ID (set when the session code is established, use an external high-entropy resource or file to build, such as a/dev/random or/dev/urandom on a UNIX system. )
; Session.entropy_length = 16
; Session.entropy_file =/dev/urandom
Session.cache_limiter = NoCache; Set to {Nocache,private,public} to (set session buffer limit)
; Determine HTTP caching aspects
Session.cache_expire = 180; Document expires after n minutes (documentation validity, in minutes)
In the Windows platform, the previous version of PHP4.01PL2 will appear after setting Session.save_path error, this is a PHP bug, PHP4.01PL2 and later has been fixed. If you use a previous version, you can set the Session.save_path to "./" or "/temp" and a directory named temp in the current packing directory where you put the PHP script (my php script is under D:apachehtdocs, Then I build a directory for temp in the D: Packing directory).
The functions of the session in PHP4 mainly include the following:
Session_Start: Initializes the session and needs to be called at the beginning of each page of the session.
Session_destroy: End session, where you need to end the session.
Session_name: Access the current session name.
Session_module_name: Access the current session module.
Session_save_path: Accesses the current session path.
SESSION_ID: Access the current session ID number.
Session_register: Registers a new session variable.
Session_unregister: Delete the registered session variable.
session_is_registered: Check if the session variable is registered.
Session_decode:session data decoding.
Session_encode:session data encryption.
Normally we only need to call three functions.
i.e. Sesssion_start (), Session_register (), session_is_registered ().
Call the Session_Start () function at the beginning of each page that needs to be used for the session.
A typical page that uses the session is as follows:
....
$var = "Hello";
Session_register ("var");//Register $var variable, note that there is no $ symbol
if (session_is_registered ("var"))//Check whether the variable is registered
echo "Haha, registered!";
Else
echo "Sorry, not yet registered!";
?>
http://www.bkjia.com/PHPjc/629567.html www.bkjia.com true http://www.bkjia.com/PHPjc/629567.html techarticle For other functions in phplib and for the use of other functions related to the session, you can refer to it with the manual or on its website to see the online documentation. It's home in HTTP://PHPLIB.NETUSE.D ...