Local Shared Object

The Flash Player has the ability to store persistent data on your computer, similar to a cookie, called a Local Shared Object. PyAMF has the ability to read and write these .sol files.

Finding the files

The Local Shared Object files are not stored in the cookies folder of your browser and the location also differs depending on the operating system you are using.

For the Windows user:

C:\Documents and Settings\{Your User Name}\Application Data\Macromedia\Flash Player\#SharedObjects\

On Linux:

/home/{Your User Name}/.macromedia/Flash_Player/#SharedObjects/

On the Mac:

/Users/{Your User Name}/Library/Preferences/Macromedia/Flash Player/#SharedObjects/

Manipulating the files

PyAMF makes it as easy as possible to interact with these files.

Loading a Local Shared Object

This file is located in my youtube.com directory, check it out on your own system (assuming you've visited youtube.com at some point ;)

from pyamf import sol

lso = sol.load('timeDisplayConfig.sol')
print lso

Which would output the following:

{u'modeDefaultSet': True, u'displayMode': u'played'}

Saving a Local Shared Object

from pyamf import sol

lso = sol.SOL('userData')
lso['username'] = 'joe.bloggs'

sol.save(lso, 'loginDetails.sol')

AMF0 & AMF3

Since the introduction of Flash 9, sol's can be read/written using AMF0 encoding or AMF3 encoding. PyAMF also supports this. When reading a sol file, PyAMF will automatically detect which encoding is used and act appropriately.

When writing a sol, the default is to use AMF0. You can override this by supplying the encoding keyword to the save function (introduced in version 0.1).

import pyamf
from pyamf import sol

lso = sol.SOL('scoreData')
lso['highScores'] = {
    'nick': 3400,
    'thijs': 3800,
    'arnar': 4500
}

sol.save(lso, 'highScores.sol', encoding=pyamf.AMF3)