Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

🔏 Utility classes for encode/decode PHP's default session data

License

Notifications You must be signed in to change notification settings

psr7-sessions/session-encode-decode

Repository files navigation

🔏 PSR7Session encoder/decoder

Build Status Scrutinizer Code Quality Code Coverage

This library provides a way to encode and decode default session data.

Installation

The suggested installation method is via composer:

composer require psr7-sessions/session-encode-decode

Why this library?

PHP's native session_encode() and session_decode() functions has some limitations:

  • session_decode()

    • Can't be used if there's no session active
    • Populates the super global $_SESSION variable automatically
  • session_encode()

    • Do not accept parameters, so you can't use it to encode the content you want.
    • Depends on $_SESSION global state

Encoding

(new PSR7SessionEncodeDecode\Encoder())->__invoke(['counter' => 2]); // 'counter|i:2;'

Decoding

(new PSR7SessionEncodeDecode\Decoder())->__invoke('counter|i:2;'); // ['counter' => 2]

About

🔏 Utility classes for encode/decode PHP's default session data

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages