Re: Session IP address matching

From: Date: Sat, 25 Jan 2014 01:57:06 +0000
Subject: Re: Session IP address matching
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-71543@lists.php.net to get a copy of this message
Hi! > I'm not aware of a way to override just read(). What would be the problem with it? You can override each method independently. > But even even if I could, how would I avoid breaking the rest of the > SessionHandler? The manual implies that read() is where (in userland PHP > terms) fopen() + assign file handle + flock() would happen. Why would you break it? Just do something like: class SessionHandlerWithIPChecks extends SessionHandler { public function SessionHandler::read($session_id) { $data = parent::read($session_id); if(!$this->doChecks($data)) { return ""; } return $data; } } Then do: session_set_save_handler(new SessionHandlerWithIPChecks()); -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

« previous php.internals (#71543) next »