View Full Version : Writing/reading cookies using Flash?

05-10-2009, 04:30 PM
I'm not quite sure if that's for here so - excuse me if it's not.

I've heard that it was possible to write/read cookies using the Flash technology.

I'm just not sure how.

So I'd like to learn more about this. Also what other info can I read - like OS, Browser, etc.?

Then another question - is it possible for a Flash object (which I understand would be needed to use Flash cookies) to read certain parameters passed from a CGI script and then pass them back?

I'm not familiar with Flash and all I need it for is for the cookies capability - for my tracking needs so is there some simple solution?

Thank you!

05-11-2009, 09:52 AM

Yes you can, or you can alternatively call Javascript to handle it, but thats probably confusing too. There are other tutorials on flash and cookies if this doesn't clarify it.

05-11-2009, 12:25 PM
Thanks for this!

How would I go to pass on this data to a script?

05-11-2009, 12:28 PM
What data exactly? You can use loadVars or similar functions to communicate from Flash with external scripts.


05-13-2009, 08:04 PM
OK. So here's the deal. I need tracking for my affiliate program.

What I mean by affiliate program?

Simple. For example John joins my affiliate program. He gets a special link like http://www.domain.com/affiliate.cgi?affID=John

So John gets people to click on that link and visit my site. If they buy John gets a commission.

The problem is tracking.

What I'm doing now is I write a simple cookie to the visitor's computer, which contains John's affID (eg. affID=John). So if the visitor doesn't buy right away and comes for example next week I can still see that it was John who referred them and split commissions with John.

These days however so many people block cookies that it's getting real hard to track who has been referred by John, and I'm VERY interested in paying John what he really deserves - because John's efforts are VITAL to my business so I must make sure he is happy and gets all his commissions.

I've heard about Flash cookies and I believe they aren't being blocked as much so they will probably be a much more precise way to track.

But since some people don't use Flash I thought that maybe I could somehow use both methods for tracking - normal cookies and Flash cookies.

What I need to do is when someone arrives at a page:

1. Check if they were referred by some of my affiliates, John for example.
2. If they have - write down a cookie in case they don't buy now and instead return later.
3. If they haven't - check if there's an existing cookie
4. Customize the order link - eg. if they were referred by an affiliate or I find a cookie with an affiliate ID - add that ID into the order link so it'll be passed to the order page and a script will do the rest. If there's no affiliate ID - add nothing to the order link.

Any ideas how I can do that?


05-13-2009, 09:40 PM
A cookie is a cookie, they are no different with Flash.

You are better off using server based methods that track the IPs of the request, and that would remove any questions with using Cookies.

05-13-2009, 09:49 PM
I can't use IP's cause not everyone has a unique IP.

I will use cookies I just want to somehow integrate both types...

First it'll check the normal cookie, if it can't find anything then it'll check the Flash one and ultimately that data has to be added to a string in a link.

That's the idea, but can it be done is the question.

05-13-2009, 11:34 PM
Well people can disable cookies in their browser or in Flash. Cookies often get cleared when the browser closes, so I would think thats the least reliable method. I delete my cookies every time FF closes, its not that uncommon these days. You could start by looking for a cookie and the IP, and use them both.

05-21-2009, 07:09 PM
OK It's been kind of hard for me to digest all that stuff since I know nothing about Flash, but please bare with me for a second.

If the Flash writes some data into an external TEXT file (as you pointed out in one of your links) would that data be somehow identifiable. Eg. there was an example with the YouTube videos sound settings. So if for example I export your sound setting into a TXT file - would it know it's your setting and recognize it when you visit again?

Or to be slightly more precise can I export a particular element in the local share objects into an external text file?