2017 © Pedro Peláez
 

library cws-session

PHP class to manipulate sessions. Data are securely encrypted and sessions are stored in database.

image

crazy-max/cws-session

PHP class to manipulate sessions. Data are securely encrypted and sessions are stored in database.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

Latest Stable Version Minimum PHP Version Build Status Code Quality Become a sponsor Donate Paypal, (*1)

:warning: Abandoned project

This project is not maintained anymore and is abandoned. Feel free to fork and make your own changes if needed., (*2)

Thanks to everyone for their valuable feedback and contributions., (*3)

CwsSession

PHP class to manipulate sessions. Data are securely encrypted and sessions are stored in database., (*4)

Installation

composer require crazy-max/cws-session

And download the code:, (*5)

composer install # or update

Getting started

Add a new table in your database with the following structure.
You can change the name of the table (sessions) but not the columns., (*6)

CREATE TABLE IF NOT EXISTS `sessions` (
  `id` varchar(128) NOT NULL,
  `id_user` int(10) unsigned NOT NULL DEFAULT '0',
  `expire` int(10) unsigned NOT NULL DEFAULT '0',
  `data` text NOT NULL,
  `skey` varchar(128) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

id - the session id.
id_user - the user id from your application. If you want to use it, use getParamUserId/setParamUserId methods.
expire - the session cache expire.
data - the session data.
skey - unique key for data encryption.
, (*7)

See tests/test.php file sample to help you., (*8)

Disconnect all users

If you want to disconnect all the users from your PHP application, execute this query :, (*9)

TRUNCATE TABLE `sessions`;

Count visitors and users connected

If you want to count visitors and users connected on your PHP application, execute this query :, (*10)

SELECT (SELECT COUNT(*) FROM `sessions` WHERE `id_user` > 0 LIMIT 1) AS nb_connected,
(SELECT COUNT(*) FROM `sessions` WHERE `id_user` = 0 LIMIT 1) AS nb_visitors;

You have to use the setParamUserId method when the user is logged in., (*11)

Example

, (*12)

Methods

process - Start the process.
start - To call everytime you want to start a new session instead of session_start().
regenerate - Regenerates the session and delete the old one. It also generates a new encryption key in the database. To use each time a user connects to your application successfully.
update - Update specific session vars (user agent, IP address, fingerprint).
isActive - Check if the session is active or not.
, (*13)

getLifetime - The session life time.
setLifetime - Set the session life time (in seconds).
getCookieDomain - The domain of the session cookie.
setCookieDomain - Set the domain of the session cookie (eg: .foo.com).
getSessionName - The session name.
setSessionName - Set the session name. (default PHPSESSID).
isFpEnable - The fingerprint enable status.
setFpEnable - Enable/disable fingerprint.
getFpMode - The fingerprint mode.
setFpModeBasic - Set the fingerprint mode basic. (default)
setFpModeShield - Set the fingerprint mode shield.
getDbExt - The database PHP extension used to store sessions.
setDbExtMysql - Set the database PHP extension used to store sessions to mysql.
setDbExtMysqli - Set the database PHP extension used to store sessions to mysqli.
setDbExtPdo - Set the database PHP extension used to store sessions to pdo. (default)
getDbPdoDriver - The PDO driver to use. (if db extension is Pdo)
setDbPdoDriverFirebird - Set the PDO driver to firebird.
setDbPdoDriverMysql - Set the PDO driver to mysql. (default)
setDbPdoDriverOci - Set the PDO driver to oci.
setDbPdoDriverPgsql - Set the PDO driver to pgsql.
setDbPdoDriverSqlite - Set the PDO driver to sqlite.
setDbPdoDriverSqlite2 - Set the PDO driver to sqlite2.
setDbPdoDriverSqlsrv - Set the PDO driver to sqlsrv.
getDbHost - The database host name or IP address.
setDbHost - Set the database host name or IP address.
getDbPort - The database port.
setDbPort - Set the database port. Leave empty if your are not sure.
setDbUsername - Set the database username.
setDbPassword - Set the database password.
getDbName - The database name.
setDbName - Set the database name.
getDbCharset - The database charset.
setDbCharset - Set the database charset. Leave empty if your are not sure.
getDbTableName - The database table name to store sessions.
setDbTableName - Set the database table name to store sessions (default 'sessions').
getParamFp - The fingerprint SESSION value.
getParamUserId - The user id SESSION value.
getParamUa - The user agent SESSION value.
getParamIp - The ip address SESSION value.
getParam - A SESSION value by key. Use this method instead $_SESSION var.
setParamUserId - Set id_user SESSION value. A user id from your application.
setParam - Set a SESSION key/value. Use this method instead $_SESSION var.
getError - The last error., (*14)

How can I help ?

All kinds of contributions are welcome :raised_hands:! The most basic way to show your support is to star :star2: the project, or to raise issues :speech_balloon: You can also support this project by becoming a sponsor on GitHub :clap: or by making a Paypal donation to ensure this journey continues indefinitely! :rocket:, (*15)

Thanks again for your support, it is much appreciated! :pray:, (*16)

License

MIT. See LICENSE for more details., (*17)

The Versions

07/06 2018

dev-master

9999999-dev https://github.com/crazy-max/CwsSession

PHP class to manipulate sessions. Data are securely encrypted and sessions are stored in database.

  Sources   Download

MIT LGPL

The Requires

 

database encrypt session

30/04 2018

1.4

1.4.0.0

  Sources   Download

30/04 2018

1.5

1.5.0.0

  Sources   Download

30/04 2018

1.6

1.6.0.0

  Sources   Download

30/04 2018

1.0

1.0.0.0

  Sources   Download

30/04 2018

1.1

1.1.0.0

  Sources   Download

30/04 2018

1.2

1.2.0.0

  Sources   Download

30/04 2018

1.3

1.3.0.0

  Sources   Download

04/01 2018

1.10

1.10.0.0 https://github.com/crazy-max/CwsSession

PHP class to manipulate sessions. Data are securely encrypted and sessions are stored in database.

  Sources   Download

MIT

The Requires

 

database encrypt session

28/11 2016

1.9

1.9.0.0 https://github.com/crazy-max/CwsSession

PHP class to manipulate sessions. Data are securely encrypted and sessions are stored in database.

  Sources   Download

LGPL

The Requires

 

database encrypt session

26/08 2016

1.8

1.8.0.0 https://github.com/crazy-max/CwsSession

PHP class to manipulate sessions. Data are securely encrypted and sessions are stored in database.

  Sources   Download

LGPL

The Requires

 

database encrypt session

22/08 2016

1.7

1.7.0.0 https://github.com/crazy-max/CwsSession

PHP class to manipulate sessions. Data are securely encrypted and sessions are stored in database.

  Sources   Download

LGPL

The Requires

 

database encrypt session