Skip to content

Instantly share code, notes, and snippets.

@anthonyholmes
Last active January 21, 2020 22:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonyholmes/608be72d1914fad23885 to your computer and use it in GitHub Desktop.
Save anthonyholmes/608be72d1914fad23885 to your computer and use it in GitHub Desktop.
Parse Session Driver for Laravel 5
<?php
namespace App;
use Parse\ParseStorageInterface;
class ParseLaravelSessionStorage implements ParseStorageInterface
{
/**
* Parse will store its values in a specific key.
*
* @var string
*/
private $storageKey = 'parseData';
public function __construct()
{
}
public function set($key, $value)
{
\Session::put($this->storageKey . '.' . $key, $value);
}
public function remove($key)
{
\Session::forget($this->storageKey . '.' . $key);
}
public function get($key)
{
if (\Session::has($this->storageKey . '.' . $key)) {
return \Session::get($this->storageKey . '.' . $key);
}
return;
}
public function clear()
{
\Session::forget($this->storageKey);
}
public function save()
{
// No action required. PHP handles persistence for $_SESSION.
return;
}
public function getKeys()
{
return array_keys(\Session::get($this->storageKey));
}
public function getAll()
{
return \Session::get($this->storageKey);
}
}
@SamuelNCarvalho
Copy link

How do I implement this class in my project ?

@aacassandra
Copy link

awesome this work
use Parse\ParseStorageInterface;

@luimi
Copy link

luimi commented Jan 21, 2020

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment