Download the PHP package narendravaghela/cakephp-remember-me without Composer
On this page you can find all versions of the php package narendravaghela/cakephp-remember-me. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download narendravaghela/cakephp-remember-me
More information about narendravaghela/cakephp-remember-me
Files in narendravaghela/cakephp-remember-me
Package cakephp-remember-me
Short Description RememberMe plugin for CakePHP
License MIT
Homepage https://github.com/narendravaghela/cakephp-remember-me
Informations about the package cakephp-remember-me
RememberMe plugin for CakePHP
This plugin provides a basic functionality to store user data in Cookies of your CakePHP applications for login and remember user in specific browser.
Read this blog post for detailed example.
Requirements
This plugin has the following requirements:
- CakePHP 3.0.0 or greater.
- PHP 5.4.16 or greater.
Installation
You can install this plugin into your CakePHP application using composer.
After installation, Load the plugin
Or, you can load the plugin using the shell command
Usage
To use this, simply load the RememberMe component from this plugin into your AppController or UsersController.
You can optionally pass the configuration options for this component.
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()
.
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.
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.
Delete data
If you need to remove user data, just call the removeRememberedData()
and it will delete the data from Cookie.
That is it.
Reporting Issues
If you have a problem with RememberMe, please open an issue on GitHub.