@@ -151,7 +151,18 @@ public function logoutAction()
151
151
session_start (); // we closed session before, must restart it to logout
152
152
$ this ->userSession ->Dao = null ;
153
153
Zend_Session::ForgetMe ();
154
- setcookie ('midasUtil ' , null , time () + 60 * 60 * 24 * 30 , '/ ' ); // 30 days
154
+ $ request = $ this ->getRequest ();
155
+ $ date = new DateTime ();
156
+ $ interval = new DateInterval ('P1M ' );
157
+ setcookie (
158
+ MIDAS_USER_COOKIE_NAME ,
159
+ null ,
160
+ $ date ->sub ($ interval )->getTimestamp (),
161
+ '/ ' ,
162
+ $ request ->getHttpHost (),
163
+ (int ) Zend_Registry::get ('configGlobal ' )->get ('cookie_secure ' , 1 ) === 1 ,
164
+ true
165
+ );
155
166
$ noRedirect = $ this ->getParam ('noRedirect ' );
156
167
if (isset ($ noRedirect )) {
157
168
$ this ->disableView ();
@@ -487,12 +498,18 @@ public function ajaxloginAction()
487
498
if ($ userDao ->getSalt () == '' ) {
488
499
$ passwordHash = $ this ->User ->convertLegacyPasswordHash ($ userDao , $ form ->getValue ('password ' ));
489
500
}
501
+ $ request = $ this ->getRequest ();
502
+ $ date = new DateTime ();
503
+ $ interval = new DateInterval ('P1M ' );
490
504
setcookie (
491
- ' midasUtil ' ,
505
+ MIDAS_USER_COOKIE_NAME ,
492
506
$ userDao ->getKey ().'- ' .$ passwordHash ,
493
- time () + 60 * 60 * 24 * 30 ,
494
- '/ '
495
- ); // 30 days
507
+ $ date ->add ($ interval )->getTimestamp (),
508
+ '/ ' ,
509
+ $ request ->getHttpHost (),
510
+ (int ) Zend_Registry::get ('configGlobal ' )->get ('cookie_secure ' , 1 ) === 1 ,
511
+ true
512
+ );
496
513
Zend_Session::start ();
497
514
$ user = new Zend_Session_Namespace ('Auth_User ' );
498
515
$ user ->setExpirationSeconds (60 * Zend_Registry::get ('configGlobal ' )->session ->lifetime );
@@ -508,14 +525,15 @@ public function ajaxloginAction()
508
525
/** Login action */
509
526
public function loginAction ()
510
527
{
511
- $ this ->Form ->User ->uri = $ this ->getRequest ()->getRequestUri ();
528
+ $ request = $ this ->getRequest ();
529
+ $ this ->Form ->User ->uri = $ request ->getRequestUri ();
512
530
$ form = $ this ->Form ->User ->createLoginForm ();
513
531
$ this ->view ->form = $ this ->getFormAsArray ($ form );
514
532
$ this ->disableLayout ();
515
533
if ($ this ->_request ->isPost ()) {
516
534
$ this ->disableView ();
517
535
$ previousUri = $ this ->getParam ('previousuri ' );
518
- if ($ form ->isValid ($ this -> getRequest () ->getPost ())) {
536
+ if ($ form ->isValid ($ request ->getPost ())) {
519
537
try {
520
538
$ notifications = array (); // initialize first in case of exception
521
539
$ notifications = Zend_Registry::get ('notifier ' )->callback (
@@ -576,18 +594,29 @@ public function loginAction()
576
594
$ passwordHash = $ this ->User ->convertLegacyPasswordHash ($ userDao , $ form ->getValue ('password ' ));
577
595
}
578
596
$ remember = $ form ->getValue ('remerberMe ' );
579
- if (!$ authModule && isset ($ remember ) && $ remember == 1 ) {
580
- if (!$ this ->isTestingEnv ()) {
597
+ if (!$ this ->isTestingEnv ()) {
598
+ $ date = new DateTime ();
599
+ $ interval = new DateInterval ('P1M ' );
600
+ if (!$ authModule && isset ($ remember ) && $ remember == 1 ) {
581
601
setcookie (
582
- ' midasUtil ' ,
602
+ MIDAS_USER_COOKIE_NAME ,
583
603
$ userDao ->getKey ().'- ' .$ passwordHash ,
584
- time () + 60 * 60 * 24 * 30 ,
585
- '/ '
586
- ); // 30 days
587
- }
588
- } else {
589
- if (!$ this ->isTestingEnv ()) {
590
- setcookie ('midasUtil ' , null , time () + 60 * 60 * 24 * 30 , '/ ' ); // 30 days
604
+ $ date ->add ($ interval )->getTimestamp (),
605
+ '/ ' ,
606
+ $ request ->getHttpHost (),
607
+ (int ) Zend_Registry::get ('configGlobal ' )->get ('cookie_secure ' , 1 ) === 1 ,
608
+ true
609
+ );
610
+ } else {
611
+ setcookie (
612
+ MIDAS_USER_COOKIE_NAME ,
613
+ null ,
614
+ $ date ->sub ($ interval )->getTimestamp (),
615
+ '/ ' ,
616
+ $ request ->getHttpHost (),
617
+ (int ) Zend_Registry::get ('configGlobal ' )->get ('cookie_secure ' , 1 ) === 1 ,
618
+ true
619
+ );
591
620
Zend_Session::start ();
592
621
$ user = new Zend_Session_Namespace ('Auth_User ' );
593
622
$ user ->setExpirationSeconds (60 * Zend_Registry::get ('configGlobal ' )->session ->lifetime );
@@ -1286,7 +1315,18 @@ public function deleteAction()
1286
1315
session_start ();
1287
1316
$ this ->userSession ->Dao = null ;
1288
1317
Zend_Session::ForgetMe ();
1289
- setcookie ('midasUtil ' , null , time () + 60 * 60 * 24 * 30 , '/ ' );
1318
+ $ request = $ this ->getRequest ();
1319
+ $ date = new DateTime ();
1320
+ $ interval = new DateInterval ('P1M ' );
1321
+ setcookie (
1322
+ MIDAS_USER_COOKIE_NAME ,
1323
+ null ,
1324
+ $ date ->sub ($ interval )->getTimestamp (),
1325
+ '/ ' ,
1326
+ $ request ->getHttpHost (),
1327
+ (int ) Zend_Registry::get ('configGlobal ' )->get ('cookie_secure ' , 1 ) === 1 ,
1328
+ true
1329
+ );
1290
1330
}
1291
1331
}
1292
1332
$ this ->_helper ->viewRenderer ->setNoRender ();
0 commit comments