When using yii to log on, I set the second parameter $ duration to 86400, which saves the user's login information to the cookie for 24 hours. {Code...} when I want to parse the cookie, I find that the cookie is like this. {Code ...} but how can I parse this... when using yii to log on, I set the second parameter $ duration to 86400, which saves the user's login information to the cookie for 24 hours.
Yii::app()->user->login($identity,86400);
When I want to parse the cookie, I find that the cookie is like this.
array(4) { ["CNZZDATA2724999"]=> string(48) "cnzz_eid=1338694115-1438177009-&ntime=1438182411" ["Hm_lvt_598eaf80391e655d10ebe38419b36fb2"]=> string(32) "1438310921,1438410705,1438589813" ["PHPSESSID"]=> string(26) "8ak62atemv5t4vc67hjrj1l705" ["abed3dd2114943c0bf392b4ae87e177b"]=> string(139) "d6991a57d52238c7b0b10d36c07f1fd9b715532ea:4:{i:0;s:2:"27";i:1;s:5:"endui";i:2;i:86400;i:3;a:2:{s:4:"role";s:1:"1";s:4:"name";s:5:"endui";}}"}
But how can I parse this cookie? What method is used?
Reply content:
When using yii to log on, I set the second parameter $ duration to 86400, which saves the user's login information to the cookie for 24 hours.
Yii::app()->user->login($identity,86400);
When I want to parse the cookie, I find that the cookie is like this.
array(4) { ["CNZZDATA2724999"]=> string(48) "cnzz_eid=1338694115-1438177009-&ntime=1438182411" ["Hm_lvt_598eaf80391e655d10ebe38419b36fb2"]=> string(32) "1438310921,1438410705,1438589813" ["PHPSESSID"]=> string(26) "8ak62atemv5t4vc67hjrj1l705" ["abed3dd2114943c0bf392b4ae87e177b"]=> string(139) "d6991a57d52238c7b0b10d36c07f1fd9b715532ea:4:{i:0;s:2:"27";i:1;s:5:"endui";i:2;i:86400;i:3;a:2:{s:4:"role";s:1:"1";s:4:"name";s:5:"endui";}}"}
But how can I parse this cookie? What method is used?
// Cookies $ cookie = array ('cnzzdata2724999 '=> 'cnzz _ eid = 1338694115-1438177009-& ntime = 000000', 'hm _ 0000' => '2017 8410705, 1434789813 ', 'phpsessid' => '8ak62atemv5t4vc67hj1_1l705 ', 'clerk' => 'salary: 4: {I: 0; s: 2: "27"; I: 1; s: 5: "endui"; I: 2; I: 86400; I: 3; a: 2: {s: 4: "role"; s: 1: "1"; s: 4: "name"; s: 5: "endui" ;}} '); // regular $ regExp ='/(a: \ d + :{. +) $ /';
/* Specify the key to store the cookie value */$ cookieUserInfo = end ($ cookie); $ getUserInfoStr = preg_match ($ regExp, $ cookieUserInfo, $ matchedStr ); $ getUserInfo = $ matchedStr [1]? Unserialize ($ matchedStr [1]): array (); print_r ($ getUserInfo );
/* If a random key is stored at a certain location */$ getUserInfo = array (); foreach ($ cookie as $ cookieUserInfo) {if (preg_match ($ regExp, $ cookieUserInfo, $ matchedStr) {$ getUserInfo = unserialize ($ matchedStr [1]); break ;}} print_r ($ getUserInfo );