- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Auth/ORM 和 auto_login 方面遇到问题。我将生命周期设置为两周,但无论浏览器是否关闭,我都会在大约一个小时后注销。事实上,它是基于时间的,因为 session 确实存在,即使在浏览器关闭后也是如此。
我已经像这样设置了东西(如果有任何帮助,我们将不胜感激!!!):
bootstrap.php
Cookie::$salt = 'some random string here';
配置/auth.php
<?php defined('SYSPATH') or die('No direct access allowed.');
return array(
'driver' => 'ORM',
'hash_method' => 'sha256',
'hash_key' => '<another random string>',
'lifetime' => 1209600, // TWO WEEKS, NO?
'session_type' => Session::$default,
'session_key' => 'auth_user',
// Username/password combinations for the Auth File driver
'users' => array(
),
);
类/ Controller /auth.php
public function action_login() { // Check to make sure the user isn't already logged in... if (Auth::instance()->logged_in() || Auth::instance()->auto_login()) {
$this->request->redirect($this->request->referrer()); }
$referrer = base64_encode($this->request->referrer());
$post = $this->request->post();
if (!empty($post))
{
$remember = isset($post['remember']); // <-- This value has been verified
Auth::instance()->login(Arr::get($post, 'email'), Arr::get($post, 'password'), $remember);
if (Auth::instance()->logged_in())
{
$this->request->redirect(base64_decode(Arr::get($post, 'referrer')));
}
else
{
$this->view->set('error', true);
}
if (isset($post['referrer']))
{
$referrer = Arr::get($post, 'referrer');
}
}
$this->view = Template::factory('auth/login');
$this->view->set('referrer', $referrer);
}
类/ Controller /website.php
class Controller_Website extends Controller {
public function before()
{
$parent_before = parent::before();
if (Auth::instance()->logged_in() || Auth::instance()->auto_login()) //<-- isn't this where the magic is supposed to be happening?!?!
{
$this->user = Auth::instance()->get_user();
}
elseif ($this->require_auth && !in_array($this->request->action(), $this->auth_allow_actions))
{
$this->request->redirect('/auth/login');
}
return $parent_before;
}
}
最佳答案
尝试像这样设置 $remember:
$remember = array_key_exists('remember', $this->request->post()) ? (bool) $this->request->post('remember') : FALSE;
关于remember-me - Kohana 3.2 验证 ORM : I can't seem to stay logged in with the "remember me" option set,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10730304/
如 https://developer.android.com/jetpack/compose/side-effects , 我们有 derivedStateOf这有助于防止不必要的重组。 有了这个,
我正在使用 AWS Cognito Identity JS SDK ( https://github.com/aws/amazon-cognito-identity-js ),并尝试设置一些按钮来测试
按照教程, 我已经使用 Auth 构建了身份验证系统。 Pyramid 的 API。 我想了解如何在登录中引入两件事(勾选框): 记住我的名字 记住我的密码 我怎样才能做到这一点?我需要做什么? 谢谢
我在 Auth/ORM 和 auto_login 方面遇到问题。我将生命周期设置为两周,但无论浏览器是否关闭,我都会在大约一个小时后注销。事实上,它是基于时间的,因为 session 确实存在,即使在
我需要在使用 django-registration 应用程序的登录表单中实现一个“记住我”按钮。任何ane可以帮助我向我展示这样做的方法吗? 谢谢 最佳答案 一种方法是更改 session 到期
我有一个函数,它从数据库检索数据并将其传递给回调。出于优化目的,我希望此数据最多每 60 秒更新一次。我的闭包函数如下所示: function delayedUpdate(fn, delay, cal
我正在编写一个配备“记住我”的登录表单,到目前为止,我读过的教程(部分是为了确保我做得正确)都说将加密的密码存储在一个 cookie 和用户名。然后,每次 PHP 检查当前用户是否未登录时,检查他们的
我正在尝试在基于 ServiceStack 的项目中实现记住我 功能。我不想使用基本身份验证,因为它需要在浏览器 cookie 中以明文形式存储密码,因此我需要想出一种易于维护和自定义到我现有数据库的
我无法“记住”在 emacs 的组织模式下工作。 我在雪豹上。 我加了 (global-set-key (kbd "C-M-r") 'org-remember)到我的 .emacs 文件但是当我尝试使
问题是关于 JS 闭包的。我有红色的定义和例子,我相信我相当了解这个机制。所以,问题是关于我不明白的具体事情。请考虑以下两个代码。代码一: function a(){ let x = 5; retur
我正在实现“记住我”功能,我希望用户不必再次输入登录名/密码。 它似乎在本地工作,但在共享主机中,它持续大约 15 分钟然后注销。这是代码: 控制者: FormsAuthentication.SetA
在我的 Android 应用程序中,我使用一组随机生成的文件名来存储一些数据。为了确保在应用程序重新启动时生成相同的文件名集 - 并且每个应用程序安装都不同 - 我通过从一长串随机字母数字字符中选择名
当我尝试在特定数据库中重新创建特定表时,MySQL 让我很伤心;我认为问题出在 MySQL 的某个地方有一些表的外键记录,并在我尝试重新创建表时不断尝试检查约束。 有问题的数据库用于测试环境,并通过转
我正在尝试弄清楚如何在我正在开发的应用程序中实现“记住我”。目前我的实现看起来像这样。 用户登录并请求被记住 服务器使用电子邮件/密码验证用户 如果验证成功,我会使用用户的电子邮件和存储在服务器上的
我正在尝试使用 PHP 和 MySQL 创建一个登录系统。我使用 cookie 是为了让用户长时间保持登录状态。 cookie 有一个随机生成的字符串,它也在数据库中。将它们相互比较并采取适当的行动。
我在 Google CodeLabs:这是代码: @Composable fun WaterCounter( modifier: Modifier = Modifier, ) { va
如何在Grails中实现“记住我”功能,以便用户可以检查它,而他又不必在2周内再次登录? 我正在使用jSecurity插件,并希望在浏览器 session 之外更改cookie的生存期。 最佳答案 S
我最近一直在思考这个问题,我想从这个很棒的社区得到一些反馈。假设用户希望在登录时被记住是否安全?如果他们使用的是公共(public)计算机,是否可以假设他们足够聪明,可以在离开前注销? 最佳答案 我真
我试图使用带有用户名和 token 的cookie向网站添加“记住我”功能,该cookie也以加密方式存储在数据库中。我的问题是该 token 应保留多长时间? One website I read说
当要记住我的cookie时,有两种不同的方法: 哈希 “记住我” cookie存储一个可以标识用户的字符串(即用户ID)和一个可以证明所标识的用户是假装的用户的字符串-通常是基于用户密码的哈希。 to
我是一名优秀的程序员,十分优秀!