Skip to content

Commit

Permalink
Use a single cookie, storing timestamp as its value
Browse files Browse the repository at this point in the history
  • Loading branch information
iMattPro committed Jun 21, 2014
1 parent ad6e381 commit 286a150
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions controller/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ protected function set_board_announcement_cookie()
// Get board announcement data from the DB text object
$announcement_timestamp = $this->config_text->get('announcement_timestamp');

// Set a 1 year long cookie
$this->user->set_cookie('ba_' . $announcement_timestamp, '1', time() + 31536000);
// Store the announcement timestamp/id in a cookie with a 1 year expiration
$this->user->set_cookie('baid', $announcement_timestamp, time() + 31536000);

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ public function display_board_announcements($event)
));

// Get announcement cookie if one exists
$cookie = $this->request->variable($this->config['cookie_name'] . '_ba_' . $board_announcement_data['announcement_timestamp'], '', true, \phpbb\request\request_interface::COOKIE);
$cookie = $this->request->variable($this->config['cookie_name'] . '_baid', '', true, \phpbb\request\request_interface::COOKIE);

// Do not continue if announcement has been disabled or dismissed
if (!$this->config['board_announcements_enable'] || !$this->user->data['board_announcements_status'] || $cookie)
if (!$this->config['board_announcements_enable'] || !$this->user->data['board_announcements_status'] || $cookie == $board_announcement_data['announcement_timestamp'])
{
return;
}
Expand Down

0 comments on commit 286a150

Please sign in to comment.