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?
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