-
-
Save catwhocode/27460d55ce1c9a37a98d to your computer and use it in GitHub Desktop.
Unserialize PHP Session in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def unserialize_session(val): | |
if not val: | |
return | |
session = {} | |
groups = re.split("([a-zA-Z0-9_]+)\|", val) | |
if len(groups) > 2: | |
groups = groups[1:] | |
groups = map(None, *([iter(groups)] * 2)) | |
for i in range(len(groups)): | |
session[groups[i][0]] = phpserialize.loads(groups[i][1]) | |
return session |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment