Jump to content

Recommended Posts

So I need a page that holds a cookie name and will tell you how much times this cookie name is visited.

 

So I got this for the form.

 

So lets say I type in the form the name Paul, next time if I type Paul again the cookie will say, hello paul you have visited this page 3 times depenting ofcourse how much time he as visited already.

 

If I will type another name like Bob, it will say, Hello bob you have visited this page 1 time.

Somebody can help with this ty.

<?php

echo "naam:<input type=\"text\" name=\"name\" size=\"20\"><br/>";
echo "<input type=\"submit\" value=\"Verzenden\" />";
?>
Link to comment
https://forums.phpfreaks.com/topic/300935-cookies-and-times-page-is-visited/
Share on other sites

ok firstly you would need to set a cookie for the page your talking about....here is a example

setcookie ('time_visited', time(), 3600, '/' , 'domain.com', true, false);

when revisiting this page again you can do something like this:

if (isset($_COOKIE['time_visited']))
{
    $time_visited = $_COOKIE['time_visited'];
    $last_visited = date('m/d/Y H:i:s', $time_visited);

    echo "Hi User, you last visited: " . $last_visted;
}

you may want to look at the manuel here regarding cookies: http://php.net/manual/en/function.setcookie.php

 

i hope this is what you are looking for

Edited by Destramic
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.