Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

The functions in this section work with the session handling capabilities of PHP. They
were added in PHP 4. To read more about their use, turn back to Chapter 7. That chapter
also includes a complete example.


boolean session_decode(string code)


Use session_decode to read encoded session data and set the values of global variables
in the session. This happens automatically when you start a session with session_start.


boolean session_destroy()


The session_destroy function eliminates all the data stored in the session. It does not
destroy the session itself, however.


string session_encode()


The session_encode function returns a string that contains encoded information about
the current session.


string session_id(string id)


Use session_id to get the value of the session identifier. If you wish to change the
session identifier, supply the optional id argument. If you do, take care to do so before
any output is sent to the browser, because the identifier is sent as a cookie.


boolean session_is_registered(string name)


The session_is_registered function returns TRUE if the specified variable is registered
with the session.


string session_module_name(string name)


The session_module_name function returns the name of the module that handles session
duties. This is the same value set by the session.save_handler directive inside
php.ini. You can change the module name if you supply the optional name argument,
but the only one available at the time of writing was the files module.


If you wish to implement your own handler in PHP, see the
session_set_save_handler function.


string session_name(string name)


The session_name function returns the current name for the session variable. The
session may be renamed with the optional name argument. This name is used as the name
of the cookie that contains the session identifier. It's also used for the back-up GET

Free download pdf