• <bdo id='JHRP1'></bdo><ul id='JHRP1'></ul>

      <small id='JHRP1'></small><noframes id='JHRP1'>

        <tfoot id='JHRP1'></tfoot>
      1. <legend id='JHRP1'><style id='JHRP1'><dir id='JHRP1'><q id='JHRP1'></q></dir></style></legend>

      2. <i id='JHRP1'><tr id='JHRP1'><dt id='JHRP1'><q id='JHRP1'><span id='JHRP1'><b id='JHRP1'><form id='JHRP1'><ins id='JHRP1'></ins><ul id='JHRP1'></ul><sub id='JHRP1'></sub></form><legend id='JHRP1'></legend><bdo id='JHRP1'><pre id='JHRP1'><center id='JHRP1'></center></pre></bdo></b><th id='JHRP1'></th></span></q></dt></tr></i><div id='JHRP1'><tfoot id='JHRP1'></tfoot><dl id='JHRP1'><fieldset id='JHRP1'></fieldset></dl></div>

        Laravel 4记住我过期时间

        Laravel 4 Remember me expire time(Laravel 4记住我过期时间)

        1. <i id='UpHe2'><tr id='UpHe2'><dt id='UpHe2'><q id='UpHe2'><span id='UpHe2'><b id='UpHe2'><form id='UpHe2'><ins id='UpHe2'></ins><ul id='UpHe2'></ul><sub id='UpHe2'></sub></form><legend id='UpHe2'></legend><bdo id='UpHe2'><pre id='UpHe2'><center id='UpHe2'></center></pre></bdo></b><th id='UpHe2'></th></span></q></dt></tr></i><div id='UpHe2'><tfoot id='UpHe2'></tfoot><dl id='UpHe2'><fieldset id='UpHe2'></fieldset></dl></div>

          <legend id='UpHe2'><style id='UpHe2'><dir id='UpHe2'><q id='UpHe2'></q></dir></style></legend>
              <bdo id='UpHe2'></bdo><ul id='UpHe2'></ul>
              1. <small id='UpHe2'></small><noframes id='UpHe2'>

                    <tbody id='UpHe2'></tbody>
                  <tfoot id='UpHe2'></tfoot>
                • 本文介绍了Laravel 4记住我过期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是 Laravel 的新手,对记住我的功能有疑问.

                  I am fairly new to Laravel and had a question regarding the remember me function.

                  我已经通过像这样将第二个参数附加到 Auth::attempt 方法成功地启用了记住我"功能.

                  I have successfully enabled the "remember me" function by attaching a second argument to the Auth::attempt method like so.

                  if (Auth::attempt(array('email' => $email, 'password' => $password), true))
                  {
                      // The user is being remembered...
                  }
                  

                  如文档中所述,这可以无限期地记住我,或者直到用户手动注销.

                  As noted in the documentation, this enables remember me indefinitely or until an user manually logs out.

                  我实际上是想在记住我"功能上设置一个过期日期.

                  I essentially want to set an expire date on the "remember me" function.

                  查看控制台,我可以看到启用记住我"会生成一个 remember_{HASH} cookie.

                  Looking at the console, I can see that enabling "remember me" generates a remember_{HASH} cookie.

                  覆盖此 cookie 中指定的过期日期以假设未来一周的最佳方法是什么?cookie 当前将日期设置为过去,从而使其永久有效.

                  What would be the best way to overwrite the expire date specified in this cookie to let say a week in the future? The cookie currently sets the date in the past, which makes it last forever.

                  请记住,我必须在 session.php 中设置 'lifetime' => 0 以便我可以根据用户偏好触发记住我的功能,因此在我的情况下将其更改为一周是行不通的.

                  Keep in mind that I had to set 'lifetime' => 0 in sessions.php so that I can trigger the remember me function based on user preference so changing this into a week would not work in my case.

                  谢谢!

                  推荐答案

                  我不知道这是否是一个好方法,但如果你不顾一切设置过期时间记住我你可以试试这个,但它对我有用.

                  I don't know whether its a good way to do it or not, but if you are desperate to set the expiration time for remember me you can try this, it works for me though.

                  让 laravel 的 Auth::attempt($credential,true) 做它的正常业务,即将记住我的过期时间设置为 5 年

                  Let the laravel's Auth::atempt($credential,true) do its normal business, i.e, setting the remember me expiration time to 5 years

                  我们将在 App::after() 方法中进行更改,因此在您的 filters.php 文件中找到 App::after() 方法和更改 cookie 过期时间

                  We will change this in App::after() method, so in your filters.php file find App::after() method and change the cookie expiration time

                  App::after(function($request, $response)
                  {
                    if ( Auth::check()){
                        $ckname=Auth::getRecallerName(); //Get the name of the cookie, where remember me expiration time is stored
                        $ckval=Cookie::get($ckname); //Get the value of the cookie
                        return $response->withCookie(Cookie::make($ckname,$ckval,360)); //change the expiration time
                    }
                  });
                  

                  注意:Cookie::make('name','value','expiration time');

                  这篇关于Laravel 4记住我过期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                        • <bdo id='CbF1A'></bdo><ul id='CbF1A'></ul>

                          <small id='CbF1A'></small><noframes id='CbF1A'>

                          <tfoot id='CbF1A'></tfoot>

                          <legend id='CbF1A'><style id='CbF1A'><dir id='CbF1A'><q id='CbF1A'></q></dir></style></legend>
                            <tbody id='CbF1A'></tbody>
                        • <i id='CbF1A'><tr id='CbF1A'><dt id='CbF1A'><q id='CbF1A'><span id='CbF1A'><b id='CbF1A'><form id='CbF1A'><ins id='CbF1A'></ins><ul id='CbF1A'></ul><sub id='CbF1A'></sub></form><legend id='CbF1A'></legend><bdo id='CbF1A'><pre id='CbF1A'><center id='CbF1A'></center></pre></bdo></b><th id='CbF1A'></th></span></q></dt></tr></i><div id='CbF1A'><tfoot id='CbF1A'></tfoot><dl id='CbF1A'><fieldset id='CbF1A'></fieldset></dl></div>