コード例 #1
0
ファイル: cargo.php プロジェクト: biggtfish/anchor-cms
 /**
  * Implementation of the read method, imports the current
  * session if found and populates the data array
  */
 public function read()
 {
     extract($this->driver->config);
     // read session ID from cookie
     $this->id = Cookie::read($cookie, 0);
     // make sure we have some data, if not lets start again
     if ($data = $this->driver->read($this->id)) {
         // set the data to an empty array
         $this->data = $data;
     } else {
         // Cargo has expired lets create a new ID to prevent session fixation
         // @see https://www.owasp.org/index.php/Session_fixation
         $this->id = noise(32);
     }
 }
コード例 #2
0
 public function read($id)
 {
     extract($this->config);
     // check if the cookie exists
     if ($encoded = C::read($cookie . '_payload')) {
         // try decoding first
         if ($decoded = base64_decode($encoded)) {
             // verify signature
             $sign = substr($decoded, 0, 32);
             $serialized = substr($decoded, 32);
             if (hash('md5', $serialized) == $sign) {
                 return unserialize($serialized);
             }
         }
     }
 }