2017 © Pedro Peláez
 

cakephp-plugin cakephp-remember-me

RememberMe plugin for CakePHP

image

danny3b/cakephp-remember-me

RememberMe plugin for CakePHP

  • Friday, May 25, 2018
  • by danny3b
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

RememberMe plugin for CakePHP

Build Status codecov.io, (*1)

This plugin provides a basic functionality to store user data in Cookies of your CakePHP applications for login and remember user in specific browser., (*2)

Read this blog post for detailed example., (*3)

Requirements

This plugin has the following requirements:, (*4)

  • CakePHP 3.0.0 or greater.
  • PHP 5.4.16 or greater.

Installation

You can install this plugin into your CakePHP application using composer., (*5)

composer require narendravaghela/cakephp-remember-me

After installation, Load the plugin, (*6)

Plugin::load('RememberMe');

Or, you can load the plugin using the shell command, (*7)

$ bin/cake plugin load RememberMe

Usage

To use this, simply load the RememberMe component from this plugin into your AppController or UsersController., (*8)

$this->loadComponent('RememberMe.RememberMe');

You can optionally pass the configuration options for this component., (*9)

$this->loadComponent('RememberMe.RememberMe', [
    'cypherKey' => "17485937564892755682047369192734583655920926", // Random unuqie string to encrypt/decrypt data. If not set, default salt value of the application will be used.
    'cookieName' => "rememberme", // Name of the cookie.
    'period' => '14 Days' // Time period
]);

Here, the basic flow should something like this: + Find the user from the database + Validate + If user has selected "Remember me" checkbox, store the user data using this component. + Next time, when user (any user) visits the application, check the stored data using getRememberedData(). + Use the data returned by getRememberedData() and validate against the database and if everything goes well, create a session of the user and make him logged in. + If user manually logs out, simply delete the data from Cookie using removeRememberedData()., (*10)

Remember data

In your login action or the action from where user logs into your application, use the rememberData() function and pass the required data of user being logged in., (*11)

$this->RememberMe->rememberData("data@example.com"); // email address of user being logged in
// or you can use the array as well
$this->RememberMe->rememberData([
  'email' => 'foo@bar.com',
  'someUniqueKey' => 'someuniquevalue'
]);

Get remembered data

Generally, in our beforeFilter() callback, we check whether user is logged in or not. Here, we can use getRememberedData() to retrieve the data that we have stored in our login action earlier. If we find something, then we can check it against our user table to check whether there is a user or not., (*12)

$isRemembered = $this->RememberMe->getRememberedData();

// code to check this data against database
// set the session
// ...

Delete data

If you need to remove user data, just call the removeRememberedData() and it will delete the data from Cookie., (*13)

That is it., (*14)

Reporting Issues

If you have a problem with RememberMe, please open an issue on GitHub., (*15)

The Versions

25/05 2018

dev-master

9999999-dev https://github.com/narendravaghela/cakephp-remember-me

RememberMe plugin for CakePHP

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp me remember

26/10 2016

v1.2

1.2.0.0 https://github.com/narendravaghela/cakephp-remember-me

RememberMe plugin for CakePHP

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp me remember

17/05 2016

v1.1

1.1.0.0 https://github.com/narendravaghela/cakephp-remember-me

RememberMe plugin for CakePHP

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp me remember

21/04 2016

v1.0

1.0.0.0 https://github.com/narendravaghela/cakephp-remember-me

RememberMe plugin for CakePHP

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp me remember