protected function insert(ISession $Session) { $symbols = str_split('qw1er2ty3ui4op5as6df7gh8jk9lz0xcvbnm'); shuffle($symbols); $length = count($symbols) - 1; for ($try = 0; $try < 1000; ++$try) { $key = ''; for ($i = 0; $i < 32; ++$i) { $key .= $symbols[mt_rand(0, $length)]; } $Session->setID($key); if ($this->Storage->add($key, $Session, $this->expiration_time)) { return true; } } trigger_error("Can't insert session after 1000 tries", E_USER_WARNING); return false; }