public function lastChangeTime()
{
$user = $this->user;
$em = $this->em;
$response = new Response();
$currentCookieValue = 0;
$currentTime = time();
$maxTime = 60;
$request = Request::createFromGlobals();
$cookies = $request->cookies;
if (!$cookies->has('lastChangeTime')) {
$response->headers->setCookie(new Cookie('lastChangeTime', time(), time() + 3600 * 48));
$response->send();
} else {
$currentCookieValue = $cookies->get('lastChangeTime');
}
if ($currentTime - $currentCookieValue > $maxTime) {
$currentCookieValue = $currentTime;
$response->headers->setCookie(new Cookie('lastChangeTime', $currentCookieValue, time() + 3600 * 48));
$response->send();
$user->setTime(time());
$em->persist($user);
$em->flush();
}
}