search
HomeBackend DevelopmentPHP Tutorial新人,如何知道一个用户访问过该网站两次了呢

新人,怎么知道一个用户访问过该网站两次了呢

本帖最后由 qilinno 于 2014-05-12 19:38:53 编辑 我是一个新人,对这方面没有概念,因此想请教下大家,
怎么知道一个用户两次访问了该网站呢?
还有网上的那些告诉用户的浏览记录是怎么实现的?
总不能是用记录IP地址吧?那又不是固定的.
比如一些贴吧,一些商城,它们就能记录用户的访问记录,而且还能根据用户的记录推荐一些商品,这是怎么做到的呢?
谢谢了!
我不要代码,只是知道怎么做就好了.

------解决方案--------------------
首先用戶登入後,把用戶的id寫入session.
當用戶訪問某一頁時,把頁面地址,用戶id,訪問時間,寫入db保存為一條紀錄。

要統計時,根據用戶id和頁面地址,就能知道該頁面被該用戶訪問了多少次。

------解决方案--------------------
引用:
Quote: 引用:

首先用戶登入後,把用戶的id寫入session.
當用戶訪問某一頁時,把頁面地址,用戶id,訪問時間,寫入db保存為一條紀錄。

要統計時,根據用戶id和頁面地址,就能知道該頁面被該用戶訪問了多少次。

请问用户的ID怎么获取呢?
是不是用户必须登录呢?
我主要是想问问类似Google推荐广告的那种方式是怎么实现的?


引用:
Quote: 引用:

首先用戶登入後,把用戶的id寫入session.
當用戶訪問某一頁時,把頁面地址,用戶id,訪問時間,寫入db保存為一條紀錄。

要統計時,根據用戶id和頁面地址,就能知道該頁面被該用戶訪問了多少次。

请问用户的ID怎么获取呢?
是不是用户必须登录呢?
我主要是想问问类似Google推荐广告的那种方式是怎么实现的?


引用:
Quote: 引用:

首先用戶登入後,把用戶的id寫入session.
當用戶訪問某一頁時,把頁面地址,用戶id,訪問時間,寫入db保存為一條紀錄。

要統計時,根據用戶id和頁面地址,就能知道該頁面被該用戶訪問了多少次。

请问用户的ID怎么获取呢?
是不是用户必须登录呢?
我主要是想问问类似Google推荐广告的那种方式是怎么实现的?


用户ID的获取可以在用户登录进行验证成功后可以把id写入session,
应该是必须登录的 现在有的商城做的猜你喜欢这个功能应该就是用类似的方法做的

------解决方案--------------------
google 广告是用用户浏览器数据,ip地址,来确定用户的。
------解决方案--------------------
引用:
关注中 用户没有登陆  如何保存用户的浏览记录 和搜素信息  等到下次用户再来访问的时候 推荐类似的信息给用户查看
有没有做过的 给个思路 就好


用户第一次登录,根据ip和时间求MD5,把这个哈希值写入cookie,作为用户标识,碰撞几率很小。服务器这边建数据表,以哈希值为主键或索引,把用户的浏览记录序列化存入。
------解决方案--------------------
像淘宝和百度的广告推送都是用用户来做的
用户一登陆,他就把喜好信息或者标示用户的方法(比如用户名什么的)扔到你的cookie里。
之后即使退出了也会显示,因为cookie还在。
也就是说你没登陆又把cookie清空,他就会显示普遍推送的东西了,因为他没法确定你是谁喜好什么。
不是用ip做的。
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Optimize PHP Code: Reducing Memory Usage & Execution TimeOptimize PHP Code: Reducing Memory Usage & Execution TimeMay 10, 2025 am 12:04 AM

TooptimizePHPcodeforreducedmemoryusageandexecutiontime,followthesesteps:1)Usereferencesinsteadofcopyinglargedatastructurestoreducememoryconsumption.2)LeveragePHP'sbuilt-infunctionslikearray_mapforfasterexecution.3)Implementcachingmechanisms,suchasAPC

PHP Email: Step-by-Step Sending GuidePHP Email: Step-by-Step Sending GuideMay 09, 2025 am 12:14 AM

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

How to Send Email via PHP: Examples & CodeHow to Send Email via PHP: Examples & CodeMay 09, 2025 am 12:13 AM

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

Advanced PHP Email: Custom Headers & FeaturesAdvanced PHP Email: Custom Headers & FeaturesMay 09, 2025 am 12:13 AM

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Guide to Sending Emails with PHP & SMTPGuide to Sending Emails with PHP & SMTPMay 09, 2025 am 12:06 AM

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

What is the best way to send an email using PHP?What is the best way to send an email using PHP?May 08, 2025 am 12:21 AM

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

Best Practices for Dependency Injection in PHPBest Practices for Dependency Injection in PHPMay 08, 2025 am 12:21 AM

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHP performance tuning tips and tricksPHP performance tuning tips and tricksMay 08, 2025 am 12:20 AM

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft