Recommend this page to a friend! |
Classes of Josantonius | PHP Session Manager | README.md | Download |
|
DownloadPHP Session libraryPHP library for handling sessions.
RequirementsThis library is supported by PHP versions 5.6 or higher. InstallationThe preferred way to install this extension is through Composer. To install PHP Session library, simply:
The previous command will only install the necessary files, if you prefer to download the entire source code you can use:
You can also clone the complete repository with Git: $ git clone https://github.com/Josantonius/PHP-Session.git Or install it manually:
Available MethodsAvailable methods in this library: - Set prefix for sessions:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $prefix | Prefix for sessions. | object | Yes | | # Return (boolean) - Get sessions prefix:
# Return (string) ? sessions prefix - Start session if session has not started:
# Return (boolean) - Add value to a session:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $key | Session name. | string | Yes | | | $value | The data to save. | mixed | No | false | # Return (boolean true) - Extract session item, delete session item and finally return the item:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $key | Item to extract. | string | Yes | | # Return (mixed|null) ? return item or null when key does not exists - Get item from session:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $key | Item to look for in session. | string | No | '' | | $secondkey | If used then use as a second key. | string|boolean | No | false | # Return (mixed|null) ? return item or null when key does not exists - Get session id:
# Return (string) ? the session id or empty - Regenerate session_id:
# Return (string) ? the new session id - Empties and destroys the session:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $key | Session ID to destroy. | string | No | '' | | $prefix | If true clear all sessions for current prefix. | boolean | No | false | # Return (boolean) Quick StartTo use this library with Composer:
Or If you installed it manually, use it:
UsageExample of use for this library: - Set prefix for sessions:
- Get sessions prefix:
- Start session:
- Add value to a session:
- Add multiple value to sessions:
- Extract session item, delete session item and finally return the item:
- Get item from session:
- Get item from session entering two indexes:
- Return the session array:
- Get session id:
- Regenerate session_id:
- Destroys one key session:
- Destroys sessions by prefix:
- Destroys all sessions:
TestsTo run tests you just need composer and to execute the following:
Run unit tests with PHPUnit:
Run PSR2 code standard tests with PHPCS:
Run PHP Mess Detector tests to detect inconsistencies in code style:
Run all previous tests:
? TODO
ContributeIf you would like to help, please take a look at the list of issues or the To Do checklist. Pull requests
Thank you to all the people who already contributed to this project! <img alt="peter279k" src="https://avatars2.githubusercontent.com/u/9021747?v=4&s=117" height="117" width="117"> | :---:| peter279k| RepositoryThe file structure from this repository was created with PHP-Skeleton. LicenseThis project is licensed under MIT license. See the LICENSE file for more info. Copyright2017 - 2018 Josantonius, josantonius.com If you find it useful, let me know :wink: |