How to identify revisiting users without login info

三世轮回 提交于 2019-12-07 12:53:40

问题


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?


回答1:


Setting cookies is very easy. In my experience the simplest way to set them is through a JQuery plugin: jquery-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.

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



来源:https://stackoverflow.com/questions/14102670/how-to-identify-revisiting-users-without-login-info

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!