By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,205 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

Visited Links

P: 1
This is not entirely a PHP question although it is based in PHP.

I have been creating a site, where I want the visitors to see the visited links as "Crossed Out" using CSS. However, I also want this effect to disappear after about 18 hours, so I used a PHP cookie to read when the last time the user visited the site was, and change the CSS so that the "visited" links had the same "Style" as the regular links. This seemed to work, however when you visited a new page, all the old "visited" links showed up again. Can you get rid of these? Or is there some other method?

In the header:
[php]
if (isset($_COOKIE[<CookieName>]))
$timeup="1"; //Cookie is present, apply visited style;
else
{
setcookie(<CookieName>, "VisitedToday", time()+72000, "/", "<WebsiteName>");
$timeup="0"; //Cookie is not present. Set Cookie;
}
[/php]
In the CSS
[php]
<?php
if ($timeup=="1")
{
echo "
.mmenus a:visited
{
color: black; font-family: arial; background-color: white; display: block; border-bottom: 1px solid black; font: 11px Sans-serif; font-weight: bold; text-decoration: line-through; text-align: center; height: 14px;
}";
}
else
{
echo "
.mmenus a:visited
{
color: black; font-family: arial; background-color: white; display: block; border-bottom: 1px solid black; font: 11px Sans-serif; font-weight: none; text-decoration: none; text-align: center; height: 14px; font-size: 10px;
}";
} ?>
[/php]
Nov 6 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.