php setcookie的链接

Here is my code i have html link like this

<a href="property-view-<?php echo $final_url;?>"  target="_blank" id="<?php echo pro_name;?>" onclick="addBuilderUrlToGoogle(<?php echo $propertyid?>);"><?php echo $pro_name;</a>

these php values coming from database it has (thousands of) number of results, here i need to set cookie for this links. If its clicked means i need to store that links in cookie and i need to show last five viewed links in another page.

If I understand, you just need to bind the setting of a cookie to the clicking of the link?

If so, you need to add an ID to your <a>:

<a href="http://www.sarvatma.org/en/" id="mylink">In English</a>

Then bind some cookie-setting code to the click event:

(Using jQuery)

$("a#mylink").bind("click", function() {
    $.cookie("TR_LNG", "English");
});

Edited. Set expires time(for example for 30 minutes):

30 minutes is 30 * 60 * 1000 miliseconds. Add that to the current date to specify an expiration date 30 minutes in the future.

 var date = new Date();
 var minutes = 30;
 date.setTime(date.getTime() + (minutes * 60 * 1000));
 $.cookie("example", "foo", { expires: date });

You don't need cookies for this. If I undertsand your problem, you simply need to keep track of the last N requests to your app from a certain user. You need users to be associated with a session, and at the top of each and every page you want to track you need to:

session_start();
$hits = $_SESSION['last_hits'];
array_push($_SESSION['last_hits'], getExternalUrl());
if (count($hits) > 5) {
  array_shift($hits);
}

You'd better implement a framework instead of manually adding this snippet at the top of every PHP file. Also note that I used getExternalUrl() because if the PHP server is reverse proxied, the request path may not contain the actual URL (not sure what you really need, tough). Appending the page token to the query string may be ok, too, but it all depends on your needs.