Changeset 1563 for trunk/src/main/php/net/stubbles/ipo
- Timestamp:
- 04/24/08 17:09:12 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ipo/session/stubNoneDurableSession.php
r1549 r1563 7 7 * @subpackage ipo_session 8 8 */ 9 stubClassLoader::load('net::stubbles::ipo::session::stubAbstractSession'); 9 stubClassLoader::load('net::stubbles::ipo::request::validator::stubRegexValidator', 10 'net::stubbles::ipo::session::stubAbstractSession' 11 ); 10 12 /** 11 13 * Session class that is not durable for more than one request. … … 21 23 * @var int 22 24 */ 23 protected $id = 312;25 protected $id; 24 26 /** 25 27 * the data … … 27 29 * @var array 28 30 */ 29 protected $data = array(); 31 protected $data = array(); 32 /** 33 * the response instance 34 * 35 * @var stubResponse 36 */ 37 protected $response; 38 /** 39 * regular expression to validate the session id 40 */ 41 const REGEX_SESSION_ID = '/^([a-zA-Z0-9]{32})$/D'; 30 42 31 43 /** … … 39 51 protected function doConstruct(stubRequest $request, stubResponse $response, $sessionName) 40 52 { 53 $this->response = $response; 54 if ($request->hasValue($sessionName) === true) { 55 $this->id = $request->getValidatedValue(new stubRegexValidator(self::REGEX_SESSION_ID), $sessionName); 56 $this->data = array(stubSession::START_TIME => time(), 57 stubSession::FINGERPRINT => '', 58 stubSession::NEXT_TOKEN => '' 59 ); 60 } elseif ($request->hasValue($sessionName, stubRequest::SOURCE_COOKIE) === true) { 61 $this->id = $request->getValidatedValue(new stubRegexValidator(self::REGEX_SESSION_ID), $sessionName, stubRequest::SOURCE_COOKIE); 62 $this->data = array(stubSession::START_TIME => time(), 63 stubSession::FINGERPRINT => '', 64 stubSession::NEXT_TOKEN => '' 65 ); 66 } else { 67 $this->id = md5(uniqid(rand(), true)); 68 } 69 70 $this->response->setCookie(stubCookie::create($sessionName, $this->id)->forPath('/')); 41 71 return true; 42 72 } … … 57 87 * @return string the session id 58 88 */ 59 public function getI D()89 public function getId() 60 90 { 61 91 return $this->id; … … 65 95 * regenerates the session id but leaves session data 66 96 */ 67 public function regenerateI D()97 public function regenerateId() 68 98 { 69 $this->id++; 99 $this->id = md5(uniqid(rand(), true)); 100 $this->response->setCookie(stubCookie::create($this->sessionName, $this->id)->forPath('/')); 70 101 } 71 102
