How to highlight new added links on front page with cookies? My front page contains say 3 different views and each view has 10 rows. My requirement is Links which were not published to the frontpage the last time the user loaded it should be highlighted. I am using common template file for field shown on front page. (that is title file with anchor tag having link to some URL) Example in image : 



I am having no idea how I can achieve this, I tried searching lot but I have idea that this can be possible with cookies. 

Please suggest that will be very helpful !!

Thanks :)

UPDATE : 

I have set nid values in cookie with below logic : 

function custom_views_pre_render(&amp;$view) {


  //frontpage highlight


  if (current_path() == "frontpage") {
    if (!empty($view-&gt;result)) {
      $nids = array();
      foreach ($view-&gt;result as $res) {
        $nids[] = $res-&gt;nid;
      }
      if(!isset($_COOKIE['FrontPage'])) {
        setcookie("FrontPage[$view-&gt;name]", implode(',', $nids), time() + (3600 * 24 * 5), '/');
      }
    }
}


Now I need to compare values of each row nid with in this array.
You could do this in a limited way where you store each item's nid and updated date in a cookie. The cookie would get updated each time the user loads the front page by JavaScript that reads the nid and date from the DOM. 

Before the cookie is updated it is used to set a highlight class on any items that aren't set in the cookie. 

In order for the cookie to not grow too large the items could be pruned by date if the front page only shows most recent. 

For an demo take a look at https://jsfiddle.net/rnc2eLxr/2/

I've included the code below.

JS libraries:


https://code.jquery.com/jquery-2.2.4.min.js
https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js


HTML:

&lt;body&gt;
  &lt;div class="view"&gt;
    &lt;ul&gt;
      &lt;li class="link"&gt;&lt;a href="http://google.com" data-nid="1" data-date="2017-01-01"&gt;Google&lt;/a&gt;&lt;/li&gt;
      &lt;li class="link"&gt;&lt;a href="http://reddit.com" data-nid="2" data-date="2017-01-02"&gt;Reddit&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
&lt;/body&gt;


Javascript:

// Get cookie value.
var linksString = $.cookie('frontLinks'),
  links = [];
if (linksString != undefined) {
  links = JSON.parse(linksString);
}

// Highlight any links not found in cookie.
$('li a').each(function(i, v) {
  var $link = $(v),
    tuple = {
      "date": $link.data('date'),
      "nid": $link.data('nid'),
    },
    match = findByNid(links, tuple.nid, true);
  if (!match) {
    $link.addClass('highlight');
    links.push(tuple)
  }
});

// Find array object by nid property.
function findByNid(inArr, nid, exists) {
  for (i = 0; i &lt; inArr.length; i++) {
    if (inArr[i].nid == nid) {
      return (exists === true) ? true : inArr[i];
    }
  }
}

// Store links in cookie.
$.cookie('frontLinks', JSON.stringify(links))


CSS:

li a.highlight {
  border: red 1px solid;
}