Login   Register  
PHP Classes

File: README.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Guilherme Blanco  >  DcSessionManager  >  README.txt  >  Download  
File: README.txt
Role: Documentation
Content type: text/plain
Description: Class documentation
Class: DcSessionManager
Manage sessions using a MySQL table to store data
Author: By
Last change: Corrected the name of the class
Date: 10 years ago
Size: 4,350 bytes


Class file image Download
 * Class: dcSessionManager.inc.php


 0 - Introduction

 This files means to describe the usage of the refering class.
 This will also include the basic usage, advanced usage and some test cases.

 It's important to remember that any feedback is apreciate. The author will love
to know that his functions is being used in project X, tips, hints, suggestions,
improvement ideas. The project can be improved under requests, suggestions, and
bug discoveries.

 This is a public package, that you can use and modify without any limitations,
as long as the credits to the author were intact. This will provide him more
enthusiam to create another ones, better and this.

 1 - Installing
 Execute the setup.sql in your MySQL server.

 2 - Class Description

 The class is very simple to be used, but the programmer must have to
provide it the basic arguments to restore a session, save it, and get it, allowing
it to works properly.

   2.1 - Constructor

   The basic usage of construtor is:

   $sess = new dcSessionManager();

   This will generate a new Session, depending of the given values.
   NOTE: A Session can be restored via COOKIE, GET or POST Method. If none of them
were defined, a new Session will be created.

     2.1.1 - Possible arguments:

     $expire (first argument) => Define the number of seconds to expire a session.
     Default value is 600 (10 minutes). The argument can be a number (I mean, numeric),
without any quotes, or the "default" string (with quotes). If not defined, the class
will assume as 600 seconds.

     $linkId (second argument) => The connection id (resource link id) to the MySQL table.
     Default if the last connection. You can send this parameter or try to use wihout it.
The class will try to use it, by taking the last connection opened.

   2.2 - Other methods

     hash $return = $sess->getHash();
     Return the hash to be send though the links.

     hash $return = $sess->regenerateHash();
     Return a new hash to be inserted in the sessHandler table. This doesn't reinsert in
the database as a security issue. The programmer must do it manually.

     boolean $return = $sess->setSaveSession( boolean $value );
     If the $value is true, the class try to store a 64 chars encrypted in the user machine,
assigning the behavior of a cookie. If the value is false, use the behavior will be a session,
and will be excluded automatically (by another acess) in the expired time. This function
returns a boolean value. If the execution succed sucessfully, it'll return TRUE, else, FALSE.

     boolean $result = $sess->setSessionValue( string $value [, ...] );
     This method register (and also update) Session values in the current Session. All the 
values here must be in a string format, but refers to an existent array, string, etc. The number 
of parameters are unlimited. Will return TRUE if the execution succed without any problems
and FALSE if not.

     boolean $result = $sess->deleteSessionValue( string $value [, ...] );
     Delete existent Session values. All the values here must be in a string format. The number
of parameters are unlimited. Will return TRUE if the execution succed without any problems
and FALSE if not.

     array $result = $sess->getSessionValues();
     Return all registered values in an associative array.
     mixed $result = $sess->getSessionValueByName( string $name );
     Return a values registered with the key $name.
     boolean $result = $sess->destroySession();
     Destroy an existent session (also unset the cookie).
     boolean $result = $sess->isRegistered( string $name );
     Returns a boolean value (TRUE/FALSE) if the system can find a key registered in the registered
Session values. This function follow the same behavior as session_is_registered($name) in PHP.

  There're some other methods defined in the class, but they're internal, and should not be used by
the programmer.

 3 - Usage
 Check out example(s) in the ZIP File.