How to uniquely identify the same user across multiple websites?
I'm doing an advertising network as a project for BS degree. I;m trying to identify the same user across multiple websites. I have a USER table in my database with ID as an auto_increment number.
In the websites i'm tracking i included the following Javascript :
function OnLoad()
{
var requestURI = window.location;
var resolution = screen.width + 'x' + screen.height;
var colorDepth = screen.colorDepth;
var query = '?requestURI=' + encodeURIComponent(requestURI)
+ '&resolution=' + encodeURIComponent(resolution)
+ '&websiteid=' + encodeURIComponent(id);
document.getElementById("body").innerHTML = "<img src ='http://dan-vaio:8080/licenta/bannerimg.gif'" + query + " width = 500 height = 200 />"; // this is the place where i want to display my banner
}
On the server side A banner choosing algorithm is called and i get 开发者_StackOverflowa queue of 5 banners that i want to display to this user. (only if the user acceseses the first time this website, otherwise i'd have to display the remaining banners in the queue. Haven't figured out how to do this either, could i keep the queue in a session ? ).
The question is : If i add a cookie to the response in the servlet, will it be avaiable when the same user acceses another website ?
i have this :
Cookie cookie = new Cookie("DisplayedBanners",visitedBanners); //
response.addCookie(cookie);
How can i uniquely identify an user? How to generate a unique ID to keep in the cookie and in the database, so when the same user accesses another website and calls my servlet i will know who he is.
Thanks a lot.
Banner queue will not work either if you use session for this. Session is maintained on the server. If you go to other site the same old session will not work here.
I would suggest that you keep this information in database.
So keep the last_shown_banner_tag with a user_id in a single table. This table should be common among the websites.
Here it is explained how to do multidomain cookies, but in PHP (requires tweaking the Apache)
http://www.tutorialized.com/tutorial/Implementing-Cross-Domain-Cookies/372
精彩评论