Javascript桥到闪存以存储SO“饼干”内闪存 [英] Javascript bridge to Flash to store SO "cookies" within flash

查看:97
本文介绍了Javascript桥到闪存以存储SO“饼干”内闪存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读此问题后,如何我可以唯一标识访问我的网站的计算机吗?


p>

 无所不在的可用性(95%的访问者可能会有

flash)

 您可以为每个Cookie存储更多数据(最多100 KB) 

跨浏览器共享,因此更有可能唯一标识一台机器

清除浏览器cookie不会删除闪存cookie。

您需要构建一个他们。


我试图找到是否有人已经做过这样的事情,所以我不会重新发明轮子。到目前为止,没有运气(也许我不知道正确的搜索词),除了代码在闪存端



我使用的是防止用户回答



有没有人知道这样做的开源库,并允许我通过javascript访问?



注意:我不知道flash,我没有许可证。



编辑:使用 evercookie

解决方案

要建立什么 rmeador ,并且为了帮助您开始使用,您需要知道如何在FLEX3 API中使用两个类, SharedObject ExternalInterface



将允许您从客户端计算机存储和检索数据, ExternalInterface 将允许您的操作脚本与您的javascript进行通信。 / p>

使用共享对象很简单。



要将数据放到用户计算机上,只需创建一个SharedObject并添加属性到sharedObject的数据属性。

  private var sharedObject:SharedObject = SharedObject.getLocal(myCookie); 
sharedObject.data.DATA_FOR_THE_COOKIE = DATA;

从SharedObject中检索数据也很简单。确保SharedObject的大小大于0(确保SharedObject存在),并通过SharedObject的数据属性查找属性名称。

  if(sharedObject.size> 0)
//从cookie访问数据 - > sharedObject.data.DATA_FROM_THE_COOKIE;

要将存储在SharedObject中的数据传递到您的javascript,您将需要使用ExternalInterface。 / p>

假设您有一个javascript函数来检索变量

  retrieveVars(vars){
//使用vars执行操作
}

要从actionscript调用此函数,您将使用

  ExternalInterface.call(retrieveVars,DATA_ITEM_1,DATA_ITEM_2,...); 

这很简单。




请注意,如果客户端的闪存播放器的存储设置设置为0,或者客户端的浏览器没有ActiveX或NPRuntime,则此技术将无法使用。


After reading this on the question How do I uniquely identify computers visiting my web site? :

A possibility is using flash cookies:

Ubiquitous availability (95 percent of visitors will probably have

flash)

You can store more data per cookie (up to 100 KB)

Shared across browsers, so more likely to uniquely identify a machine

Clearing the browser cookies does not remove the flash cookies.

You'll need to build a small (hidden) flash movie to read and write them.

I tried to find if someone has already done something like this, so I wouldn´t have to reinvent the wheel. So far, no luck(maybe I don´t know the right term to search), except for the code in the flash side

The use I have for this is to prevent a user to answer a quiz multiple times, but future uses maybe banning trolls.

Does anyone knows a open source library that does this and allows me to access via javascript?

Caveats: I don't know flash and I don't own a license.

Edit: You can do that using evercookie. It's kind of evil, but works.

解决方案

To build on what rmeador said, and to help get you started, you are going to need to know how to use two classes in the FLEX3 API, SharedObject and ExternalInterface.

SharedObject will allow you to store and retrive data from a client computer and ExternalInterface will allow your actionscript to communicate with your javascript.

Using shared object is simple.

To put data onto a users machine just create a SharedObject and add properities to the sharedObject's data properity.

  private var sharedObject : SharedObject = SharedObject.getLocal("myCookie");
  sharedObject.data.DATA_FOR_THE_COOKIE = DATA;

Retriving data from the SharedObject is just as simple. Make sure the size of the SharedObject is greater than 0 (Make sure the SharedObject exists) and the just look up the properity names through the SharedObject's data properity.

if(sharedObject.size > 0)
       // access data from cookie with -> sharedObject.data.DATA_FROM_THE_COOKIE;

To pass the data stored in the SharedObject to your javascript you are going to need to use ExternalInterface.

Lets say you have a javascript function to retrieve the variables

function retrieveVars( vars ){
   // Do something with vars.
}

To call this function from actionscript you will use

ExternalInterface.call("retrieveVars", DATA_ITEM_1, DATA_ITEM_2, ...);

Its that simple.

Please note that this technique will not work if the client's flash player has its storage settings set at 0, or if the client's browser does not have ActiveX or NPRuntime.

这篇关于Javascript桥到闪存以存储SO“饼干”内闪存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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