有什么方法可以唯一地识别访问我的网站网络的用户吗?
有没有什么方法,最好是在java中,来唯一地标识一个用户?
我有以下场景:我拥有 10 个网站,我想知道同一用户何时访问我的任何网站。因此,如果用户访问站点 A,然后访问站点 B,我想得到以下问题的答复:该特定用户之前访问过站点 A 吗?
跟踪 IP 是一个糟糕的方法,因为大多数 IP 都是动态的,或者更多的人通过路由器共享相同的 IP。
我猜测获取 MAC 地址是一个安全分支:)。
Cookie 仅适用于特定网址!?
有什么办法可以让它工作吗?
编辑:
我读到不可能跨多个域访问相同的 cookie。到底有可能吗?这是参考:at: IE 和 Chrome 的 Cookie 问题(工作使用java)“Cookies是基于域的。许多浏览器拒绝嵌入资源(CSS / JS /图像)上的cookies,这些资源是从其他域提供的,而不是页面提供的”
所以如果我添加一个response.addCookie(UniqueCookieForCurrentUser);
它可以在其他域上使用吗?
正如您所建议的,我正在从 javascript 调用:
var query = '?requestURI=' + encodeURIComponent(requestURI)
+ '&resolution=' + encodeURIComponent(resolution)
+ '&websiteid=' + encodeURIComponent(id)
+ '&DisplayedBanners=' + encodeURIComponent(DisplayedBanners);
document.getElementById("body").innerHTML = "<img src ='http://dan-vaio:8080/licenta/bannerimg.gif" + query + "' width = 728 height = 90 />";
在 servlet 中我返回此:(将 cookie 添加到响应后)
File f = new File(filePath);
byte[] b = new byte[(int)f.length()];
FileInputStream fis = new FileInputStream(f);
fis.read(b);
ServletOutputStream out = response.getOutputStream();
out.write(b);
out.close();
Is there any way, preferable in java, to uniquely identify a user?
I have the following scenario: I own 10 websites and i want to know when the same user accesses any of my websites. So if a user accesses site A, and after that he accesses site B i want to get a response to the question : Did this particular user accessed site A before?
Keeping track of the IP is a poor approach as mostly IPs are dynamic or more people share the same ip through a router.
I'm guessing that getting the MAC Address is a security branch :).
Cookies are available only for a specific url !?
Is there any way i can get this working?
EDIT:
I read that's not possbile to access the same cookie across multiple domains. Is it possbile after all ? Here's the reference : at: Cookie problems with IE and Chrome (working with java) "Cookies are domain based. Many browsers reject cookies on embedded resources (CSS/JS/images) which are served from other domain than the page is been served from"
So if i add a response.addCookie(UniqueCookieForCurrentUser);
will it be available on other domains ?
I'm calling, as you suggested, from javascript :
var query = '?requestURI=' + encodeURIComponent(requestURI)
+ '&resolution=' + encodeURIComponent(resolution)
+ '&websiteid=' + encodeURIComponent(id)
+ '&DisplayedBanners=' + encodeURIComponent(DisplayedBanners);
document.getElementById("body").innerHTML = "<img src ='http://dan-vaio:8080/licenta/bannerimg.gif" + query + "' width = 728 height = 90 />";
And in servlet i return this: (after adding the cookie to the response)
File f = new File(filePath);
byte[] b = new byte[(int)f.length()];
FileInputStream fis = new FileInputStream(f);
fis.read(b);
ServletOutputStream out = response.getOutputStream();
out.write(b);
out.close();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像所有广告网络一样:您在每个站点上放置一个小网络错误,从您的一台服务器加载 cookie,这样无论用户访问哪个站点,他们总是从同一个错误服务器获取 cookie。将唯一标识符放入每个站点的错误中,这样您就不需要依赖引用来识别错误服务器上每次点击的源站点。
以下:
好的。在每个站点上,您将在每个着陆页上都有此内容:
并将
siteName
替换为适合每个站点的内容。例如src=siteA
、src=siteB
等...当用户进入站点 A 时,他们的浏览器将从您的 webbug 服务器加载此图像和 cookie将被发布以识别用户。 PHP 会话 cookie,或者类似于 Apache 的 mod_usertrack 生成的 cookie)。重要的是 cookie 的值对于每个用户来说都是唯一的。
现在,该用户的浏览器中有一个 Cookie,
example.com.track=2536t4234235423423
。当用户访问站点 B 时,浏览器会将此 cookie 与图像请求一起发送到网络错误服务器,现在您的日志将显示 cookie 2536t4234235423423 已访问站点 A 和站点 B。该 cookie 本身是无用的,它只是识别一个用户。但结合从网络错误服务器请求的 URL(其中包含原始服务器的名称),您可以看到任何特定 cookie(例如用户)访问了哪个站点。
Do as all ad networks do: You place a small web bug on each site that loads a cookie from ONE of your servers, so that regardless of which site the user goes to, they always get a cookie from the same bug server. Put a unique identifier into each site's bug so that you're not dependent on referers to identify the source site for each hit on the bug server.
following:
Ok. on each site you'll have this on each landing page:
and replace
siteName
with something appropriate for each site. e.g.src=siteA
,src=siteB
, etc...When a user comes in to site A, their browser will load this image from your webbug server, and a cookie will be issued to identify the user. A PHP session cookie, or something like the one generated by Apache's mod_usertrack). The important thing is that the cookie's value is UNIQUE for each user.
So now this user has a cookie in their browser,
example.com.track=2536t4234235423423
. When the user then visits site B, the browser will send this cookie along with the image request to the web bug server, and now your logs will show that cookie 2536t4234235423423 has visited both site A and site B.The cookie by itself is useless, it just identifies a user. But in combination with the URL requested from the web bug server, which contains the name of the originating server, you can then see which site any particular cookie (e.g. user) visited.