danny3b/cakephp-remember-me
Composer 安装命令:
composer require danny3b/cakephp-remember-me
包简介
RememberMe plugin for CakePHP
README 文档
README
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.
composer require narendravaghela/cakephp-remember-me
After installation, Load the plugin
Plugin::load('RememberMe');
Or, you can load the plugin using the shell command
$ bin/cake plugin load RememberMe
Usage
To use this, simply load the RememberMe component from this plugin into your AppController or UsersController.
$this->loadComponent('RememberMe.RememberMe');
You can optionally pass the configuration options for this component.
$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().
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.
$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.
$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.
That is it.
Reporting Issues
If you have a problem with RememberMe, please open an issue on GitHub.
danny3b/cakephp-remember-me 适用场景与选型建议
danny3b/cakephp-remember-me 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 05 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cakephp」 「remember」 「me」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 danny3b/cakephp-remember-me 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 danny3b/cakephp-remember-me 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 danny3b/cakephp-remember-me 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
CakePHP plugin that performs Remember-me authentication with the new cookie algorithm of version 3.5 or later
Query caching for Laravel 5
Email Toolkit Plugin for CakePHP
Rhino, a CMS and Application-Framework plugin for CakePHP
A CakePHP plugin for sending mail via SparkPost's REST API
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-05-25