Download the PHP package pixxel/session without Composer
On this page you can find all versions of the php package pixxel/session. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package session
PHP Session library
A fork from the great library from josantonius, check him out here: https://github.com/josantonius/php-session
Did a fork to have our namespace across our own libraries and his.
PHP library for handling sessions.
Version 1.x is considered as deprecated and unsupported. In this version (2.x) the library was completely restructured. It is recommended to review the documentation for this version and make the necessary changes before starting to use it, as it not be compatible with version 1.x.
- Requirements
- Installation
- Available Methods
- Quick Start
- Usage
- Tests
- TODO
- Changelog
- Contribution
- Sponsor
- License
Requirements
This library is compatible with the PHP versions: 8.0 | 8.1.
Installation
The 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:
Available Methods
Available methods in this library:
Starts the session
@see https://php.net/session.configuration
for List of available $options
and their default values
@throws SessionException
If headers already sent
@throws SessionException
If session already started
@throws SessionException
If setting options failed
@Return bool
Check if the session is started
@Return bool
Sets an attribute by name
@throws SessionException
If session is unstarted
@Return void
Gets an attribute by name
Optionally defines a default value when the attribute does not exist.
@Return mixed
Value
Gets all attributes
@Return array
$_SESSION content
Check if an attribute exists in the session
@Return bool
Sets several attributes at once
If attributes exist they are replaced, if they do not exist they are created.
@throws SessionException
If session is unstarted
@Return void
Deletes an attribute by name and returns its value
Optionally defines a default value when the attribute does not exist.
@throws SessionException
If session is unstarted
@Return mixed
Attribute value
Deletes an attribute by name
@throws SessionException
If session is unstarted
@Return void
Free all session variables
@throws SessionException
If session is unstarted
@Return void
Gets the session ID
@Return string
Session ID
Sets the session ID
@throws SessionException
If session already started
@Return void
Update the current session id with a newly generated one
@throws SessionException
If session is unstarted
@Return bool
Gets the session name
@Return string
Session name
Sets the session name
@throws SessionException
If session already started
@Return void
Destroys the session
@throws SessionException
If session is unstarted
@Return bool
Quick Start
To use this library with Composer:
Or instead you can use a facade to access the methods statically:
Usage
Example of use for this library:
- Starts the session
Without setting options:
Setting options:
Using the facade:
- Check if the session is started
Using session object:
Using the facade:
- Sets an attribute by name
Using session object:
Using the facade:
- Gets an attribute by name
Without default value if attribute does not exist:
With default value if attribute does not exist:
Using the facade:
- Gets all attributes
Using session object:
Using the facade:
- Check if an attribute exists in the session
Using session object:
Using the facade:
- Sets several attributes at once
Using session object:
Using the facade:
- Deletes an attribute by name and returns its value
Without default value if attribute does not exist:
With default value if attribute does not exist:
Using the facade:
- Deletes an attribute by name
Using session object:
Using the facade:
- Free all session variables
Using session object:
Using the facade:
- Gets the session ID
Using session object:
Using the facade:
- Sets the session ID
Using session object:
Using the facade:
- Update the current session id with a newly generated one
Regenerate ID without deleting the old session:
Regenerate ID by deleting the old session:
Using the facade:
- Gets the session name
Using session object:
Using the facade:
- Sets the session name
Using session object:
Using the facade:
- Destroys the session
Using session object:
Using the facade:
Tests
To run composer and to execute the following:
Run unit tests with PHPUnit:
Run code standard tests with PHPCS:
Run PHP Mess Detector tests to detect inconsistencies in code style:
Run all previous tests:
TODO
- [ ] Add new feature
- [ ] Improve tests
- [ ] Improve documentation
- [ ] Improve English translation in the README file
- [ ] Refactor code for disabled code style rules. See phpcs.xml
- [ ] Show an example of renewing the session lifetime
- [ ] Feature to enable/disable exceptions?
- [ ] Feature to add prefixes in session attributes?
Changelog
Detailed changes for each release are documented in the release notes.
Contribution
Please make sure to read the Contributing Guide, before making a pull request, start a discussion or report a issue.
Thanks to all contributors! :heart:
Sponsor
If this project helps you to reduce your development time, you can sponsor Josantonius to support my open source work :blush:
License
This repository is licensed under the MIT License.
Copyright © 2017-present, Josantonius