You are here

function popup_onload_save_time_cookie in Popup On Load 7

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

Save popup display time into the cookie.

Parameters

object $popup_onload: Popup object.

2 calls to popup_onload_save_time_cookie()
popup_onload_action_display_popup in ./popup_onload.rules.inc
Action to display a popup.
popup_onload_save_cookie in ./popup_onload.module
AJAX gate for popup cookie saving.

File

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

Code

function popup_onload_save_time_cookie($popup_onload = NULL) {
  $cookie_name = variable_get(POPUP_ONLOAD_VAR_COOKIE_NAME, POPUP_ONLOAD_DEFAULT_COOKIE_NAME);
  if (isset($popup_onload->cookie_lifetime_single) && !empty($popup_onload->cookie_lifetime_single)) {
    $expire_seconds = $popup_onload->cookie_lifetime_single;
    $cookie_name .= '_' . $popup_onload->popup_id;
  }
  else {
    $expire_seconds = variable_get(POPUP_ONLOAD_VAR_COOKIE_LIFETIME, POPUP_ONLOAD_DEFAULT_COOKIE_LIFETIME);
  }
  $cur_time = time();
  setcookie($cookie_name, $cur_time, $cur_time + $expire_seconds, '/');
}