Example #1
0
 public function write($id, $data)
 {
     $repository = $this->entityManager->getRepository(Session::class);
     $session = $repository->find($id);
     if (!$session) {
         $session = new Session($id, $this->getUserAgent(), $this->getRemoteAddress());
     }
     $session->setData($data);
     $session->setLastModified(new DateTime());
     $session->setLifetime($this->lifetime);
     $this->entityManager->persist($session);
     $this->entityManager->flush($session);
     return true;
 }