change color after a page was visited using Bootstrap

0

It seems that doing this does not have an effect:

a:visited{
   color: #red;
}

Is there another possibility of knowing which page the person has already visited?

I'm using php

    
asked by anonymous 05.06.2016 / 06:06

1 answer

0

Using cookies you can check if a page has been visited.

For example:

setcookie("visitado", "1" /*, time() + 3600 */);

Where the third parameter that was omitted sets the cookie to expire in one hour, when omitted the cookie is only valid until the browser is closed.

Remember that the cookie must be created before any output, so it is best to create it at the beginning of the code.

In your layout file you would do something like:

<a class="<?= key_exists("visitado", $_COOKIE) ? 'visited' : '' ?>">Página inicial</a>

And in your css file:

.visitado {
  color: red;
}
    
23.02.2017 / 01:13