-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathBrowserCookies.as
More file actions
55 lines (46 loc) · 1.72 KB
/
Copy pathBrowserCookies.as
File metadata and controls
55 lines (46 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package {
import flash.display.Sprite;
import flash.external.ExternalInterface;
import flash.net.URLVariables;
public class BrowserCookies extends Sprite
{
//this will parse the cookie data
public var _urlVariables:URLVariables;
/**
* Return all the cookie values in one object
* @return URLVariables
*
*/
public function getUrlVariables() : URLVariables {
return _urlVariables;
}
/**
* Return one cookie value
* @param value String
* @return String
*
*/
public function getCookieValue(value:String) : String {
var returnValue:String = "";
if(_urlVariables && _urlVariables[value]) {
returnValue = _urlVariables[value];
}
return returnValue;
}
/**
* This will connect to the browser and pull cookies into flash
*/
public function BrowserCookies() : void{
//this will hold the data returned from javascript
var browserCookieString:String;
//pull the data from javascript
browserCookieString = ExternalInterface.call("function(){return document.cookie}");
//replace ; with & to make it look like a url
browserCookieString = browserCookieString.replace(/;\s/g, "&");
//parse the cookie string into variables. you can now access cookie variables as properties of this object
if(browserCookieString) {
_urlVariables = new URLVariables(browserCookieString);
}
}
}
}