Skip to content
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.

wplibs/session

Repository files navigation

WP Session Build Status

The missing Session manager for WordPress

Installation

composer require wplibs/session:^1.0

Usage

<?php

use WPLibs\Session\WP_Session;

$session = new WP_Session('my_plugin_session', [
    'lifetime'        => 1440,  // The session lifetime in minutes.
    'expire_on_close' => false, // If true, the session immediately expire on the browser closing.
    'cookie_name'     => null,
]);

// Must call before the `init` hook.
$session->hooks();

// In some where:
$session['user_address'] = 'Some where';

// Retrive
dump($session['user_address']);