如何在没有登录信息的情况下识别正在访问的用户 [英] How to identify revisiting users without login info

查看:66
本文介绍了如何在没有登录信息的情况下识别正在访问的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的网站创建一个推荐引擎.假设某个用户访问了我的网站.我想向他推荐他还可以查看哪些其他产品.我可以创建一个推荐引擎.但是,如何找到模式?我想的是,如果我能以某种方式知道某个用户浏览了哪些产品,那么我可以在其中找到一种模式并向另一位用户提出建议.但是,是否可以在不登录用户的情况下进行此信息跟踪?跟踪IP地址可能是一种方法,但IP可能是动态的.我听说过Cookie.请帮我.是否有任何API?

I want to create a recommendation engine for my website. Suppose a user comes to my website. I want to recommend him what other products he can view. I can create a recommendation engine. But, how to find patterns? What I have thought is, if by any means I can know which products were browsed by an user, I can find a pattern in that and suggest to another user. But, is this information tracking possible without making the user login? Tracking IP address may be one way, but IP may be dynamic. I have heard about cookies. Please help me. Are there any APIs for this?

推荐答案

设置cookie非常容易.以我的经验,最简单的设置方法是通过 JQuery 插件:

Setting cookies is very easy. In my experience the simplest way to set them is through a JQuery plugin: jquery-cookie.

对于您的任务,您可以设置一个具有随机几乎唯一 ID的cookie(请检查

For your task you can set a cookie with a random almost-unique ID (check this question to know how) the first time the user open your website. For example

$.cookie('user_id', 'the_random_id');

当用户回来时,您可以读取该值

When the user come back you can read that value

user_id = $.cookie('user_id')

并在数据库中检查有关该用户的相对信息.

and check in your database the relative information about that user.

很明显,如果用户不接受cookie或将其删除,则无法识别他.

Obviously if an user does not accept cookies or deletes them you cannot identify him.

这篇关于如何在没有登录信息的情况下识别正在访问的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆