开发者

javascript, cookie, php and many more with ecommerce

开发者 https://www.devze.com 2023-03-28 12:24 出处:网络
I\'m working on a website which is e commerce website I\'ve done all but i\'m not good with cookies so my client says that he want to know that the person who buy products from it how many times visi

I'm working on a website which is e commerce website I've done all but i'm not good with cookies so my client says that he want to know that the person who buy products from it how many times visited before by date , by time its open site so anyone can visit no session use, I'm totally confused with开发者_StackOverflow社区 it huh


you def need a cookie, maybe store the user's ip address and current date on that cookie:

//user details
$ip = $_SERVER['REMOTE_ADDR'];
$date = date("Y-m-d H:i:s");

//set a cookie for 1 month                        
setcookie("users", $ip.','.$date, time() + 60 * 60 * 24 * 30);

then every time the user logs in read that cookie, if it doesn't exist then set the cookie if it does exist add another value for the date. When you want to know how many times a user visited your site just get all the date values from that cookie.

0

精彩评论

暂无评论...
验证码 换一张
取 消