Tuesday, July 8, 2008

A comparison of Browser Cookies and Shared Objects in Flash/Flex

I was facing a problem for storing some session info in my Adobe Flex based chat client so I went through a lot about Using Cookies and Shared Objects in Flex and thought will write the gist for fellow developers.

For storing browser cookies in flash/flex we have two approaches:
  1. Use Flex Shared Object approach - Shared Objects are used to store data on the client machine in much the same way that data is stored in a cookie created through a web browser. The data can only be read by movies originating from the same domain that created the Shared Object. This is the only way Macromedia Flash Player can write data to a user's machine. Shared Objects can not remember a user's e-mail address or other personal information unless they willingly provide such information.
    SharedObjects are the Full extension for normal Browser cookies, because it has features that are not in normal browser cookies.
    The Basic meaning is same “They are used for storing client data on the client Harddisk”.And access them through out the site when live or access them on next visit.

    There are two types of Shard Objects- Local Shared objects and Remote Shared Objects. Local Shared Objects are stored on User's harddisk and Remote ones are stored on a different machine or server (accessed using RTMP).

  2. Storing Info in browser cookies - Using Flex you cannot directly store info in browser cookies. It does not allow that. You have to call an External Script (like JavaScript, ASP, PHP) to do that for you.