Source of file SessionDataStore.php
Size: 1,733 Bytes - Last Modified: 2021-12-23T10:20:09+00:00
/var/www/docs.ssmods.com/process/src/src/Ctct/Auth/SessionDataStore.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 | <?php namespace Ctct\Auth; use Ctct\Auth\CtctDataStore; /** * Example implementation of the CTCTDataStore interface that uses session for access token storage * * @package Auth * @author Constant Contact */ class SessionDataStore implements CtctDataStore { public function __construct() { session_start(); if (!isset($_SESSION['datastore'])) { $_SESSION['datastore'] = array(); } } /** * Add a new user to the data store * @param string $username - Constant Contact username * @param array $params - additional parameters */ public function addUser($username, array $params) { $_SESSION['datastore'][$username] = $params; } /** * Get an existing user from the data store * @param string $username - Constant Contact username */ public function getUser($username) { if (array_key_exists($username, $_SESSION['datastore'])) { return $_SESSION['datastore'][$username]; } else { return false; } } /** * Update an existing user in the data store * @param string $username - Constant Contact username * @param array $params - additional parameters */ public function updateUser($username, array $params) { if (array_key_exists($username, $_SESSION['datastore'])) { $_SESSION['datastore'][$username] = $params; } } /** * Delete an existing user from the data store * @param string $username - Constant Contact username */ public function deleteUser ($username) { unset($_SESSION['datastore'][$username]); } } |