a lot of time has gone by since my last post, I’m quite busy at the moment. But this didn’t stop me from setting up this post. I have written a small utility class which I think some of you really would like to use. It is a small class that makes it possible to set Cookies via Actionscript without adding anything to the HTML Wrapper, all the code will be injected at runtime.
I have packaged the whole thing as a ready to use flex project but feel free to use it in any other Actionscript 3 environment (Flash or pure AS3). You can grab the files here http://depositfiles.com/files/ry60vxfh8
The Util comes with methods for setting, getting and removing cookies – as mentioned before you do not have to change a single line in your wrapper, just import the class and start setting cookies from flash or flex. I have made this util because of some concerns using Flash Cookies (Shared Objects) with Internet Explorer 6 – now i do not use Shared Objects anymore if I do not really need them. I really do not know why this doesn’t come with any of the Adobe utils.
To use the util, download the file and put the de/aggro/utils/CookieUtil into your source folder, then try the following:
import de.aggro.utils.CookieUtil; //Set a cookie named mycookie with a value of mycookie value with a time to live of 30 days CookieUtil.setCookie("mycookie", "mycookie value", 30); //Get that cookie and trace its value trace(CookieUtil.getCookie("mycookie")); //Delete the cookie from the users computer CookieUtil.deleteCookie("mycookie");
Feel free to use the util for any commercial, private or educational purposes and drop me a comment if you like it.
Wow, I can’t believe how many people claim this as their own code – I’m not complaining but just renaming or removing the package name isn’t enough for a cheap copy 🙂 Here are some examples (my js functions name starts with ‘snw_’ – this is our shirtnetwork prefix so this is quite funny to see):
http://code.google.com/p/goodboyxmeangirl/source/browse/trunk/railk/as3/utils/CookieUtil.as (he dropped a comment, so everything fine here now) http://workingsoftwaresolutions.blogspot.com/2010/01/cookie-setting-in-flex-actionscript.html (added link to this post, changed package name – no problem)
And here is one I like, he links to this post and he didn’t rename the package to claim it as his own (at least i think that):
Guys if you take the util this is fine, but if you just rename the package and put it onto your page without a backlink this sucks .