Download the PHP package lithemod/session-support without Composer

On this page you can find all versions of the php package lithemod/session-support. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package session-support

Session Support

Installation

To use the lithemod/session-support component in your PHP application, you can install it via Composer. If you don’t have Composer installed, you can download it from getcomposer.org.

Step 1: Install Composer

If you haven't installed Composer yet, run the following command in your terminal:

Step 2: Add lithemod/session-support to Your Project

Navigate to your project directory and run the following command:

This command will download the package and update your composer.json file accordingly.

Step 3: Start a Session

To use the session functionality, make sure to start a PHP session at the beginning of your script:

Using the Session Class

The Session class provides a simple and intuitive interface for managing session variables in your PHP applications. Below are detailed descriptions of each method along with examples.

Setting a Session Variable

You can set a session variable using the put method. This method accepts the name of the session variable and the value you want to assign.

Retrieving a Session Variable

To retrieve the value of a session variable, use the get method. You can also specify a default value to return if the session variable does not exist.

Removing a Session Variable

To remove a specific session variable, use the forget method. You can pass a single variable name or an array of names to remove multiple variables at once.

Destroying All Session Variables

If you need to clear all session variables, you can use the destroy method:

Checking if a Session Variable Exists

To check if a specific session variable exists, you can use the has method. This method can also accept an array of variable names.

Regenerating the Session ID

For security reasons, it's often a good practice to regenerate the session ID. Use the regenerate method to do this:

Retrieving the Current Session ID

You can retrieve the current session ID using the getId method:

Setting a Custom Session ID

If you need to set a custom session ID, you can do this with the setId method:

Retrieving All Session Variables

To retrieve all session variables as an associative array, use the all method:

Magic Methods

You can also use object property syntax to set and retrieve session variables with the magic methods __set and __get.

Error Handling

If you try to use session methods without starting a session, a RuntimeException will be thrown:

Flash Message Support

The Flash class allows you to manage flash messages in sessions. Flash messages are used to store temporary information that should be displayed on the next request.

Setting a Flash Message

You can set a flash message using the set method or directly through the property:

Retrieving a Flash Message

To retrieve a flash message and remove it from the session, use the get method or the magic property:

Checking for Flash Messages

To check if a flash message exists, use the has method:

Keeping Flash Messages

If you need to keep a flash message for the next request, use the keep method:

Security Best Practices

When working with sessions in web applications, follow these security best practices:

Final Considerations

This comprehensive guide provides the necessary details for users to effectively implement and manage sessions and flash messages in their PHP applications using the lithemod/session-support component. With the recommended practices and the examples provided, you'll be well-equipped to handle session management effectively and securely. If you have any questions or need further assistance, feel free to ask!


All versions of session-support with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lithemod/session-support contains the following files

Loading the files please wait ....