You are here

function popup_onload_save_time_cookie in Popup On Load 8

Same name and namespace in other branches
  1. 7 popup_onload.module \popup_onload_save_time_cookie()

Save popup display time into the cookie.

1 call to popup_onload_save_time_cookie()
PopupOnloadController::getPopup in src/Controller/PopupOnloadController.php
Get popup.

File

./popup_onload.module, line 192
Contains main popup_onload hooks and functions.

Code

function popup_onload_save_time_cookie($popup_onload) {
  $cookie_name = PopupOnLoadSettingsForm::popupOnLoadGetDefaults(POPUP_ONLOAD_VAR_COOKIE_NAME, POPUP_ONLOAD_DEFAULT_COOKIE_NAME) . '_' . $popup_onload
    ->id();
  $expire_seconds = PopupOnLoadSettingsForm::popupOnLoadGetDefaults(POPUP_ONLOAD_VAR_COOKIE_LIFETIME, POPUP_ONLOAD_DEFAULT_COOKIE_LIFETIME);
  $cur_time = time();
  $response = new Response();
  $cookie = new Cookie($cookie_name, $cur_time, $cur_time + $expire_seconds, '/');
  $response->headers
    ->setCookie($cookie);
  $response
    ->sendHeaders();
}