Pages

Sunday, June 13, 2010

Blocked OpenID provider? Can't log in Stack Overflow? A workaround

My favorite browser is Firefox and this post is about modifying Firefox cookies. Geeky solution, I know!

The problem

At my work, various URLs are blocked. For example, I can use Google as my main search engine, but I cannot sign in Google home page. Thus, many of the Google services are inaccessible, including my OpenID.

So, I can't use my OpenID to log in my Stack Overflow account. From my home, of course, I can. And I could use another OpenID provider to activate the second account which SO provides, but I don't want to keep around multiple OpenID accounts.

The workaround

Thankfully (?), Stack Overflow only tracks the cookies in our computer, it doesn't care if we are actually logged in our OpenID provider. If the right cookie exists, then bingo! We are in.

Firefox 3 (v3.6.3 currently) uses SQLite database as a storage format. Text format belongs to the past due to its natural limitations, e.g. provides no support for organizing persisted data. Check out DOM Storage for more info.

In order to modify Firefox cookies we need a SQLite manager and (of course) SQL knowledge. Gotcha!

If you don't have a SQLite manager, you can download SQLiteSpy, which is a single executable and doesn't require installation.

Still reading?

On Windows XP, Firefox cookies.sqlite location is:
\Documents and Settings\USERNAME\Application Data\Mozilla\Firefox\
Profiles\v1egdb8r.default\cookies.sqlite

If the Firefox is running we cannot open the cookies file, because it'll be locked. First we must close the browser.

Now, if we open cookies we'll see something like this:



Every cookie record contains 9 fields: id, name, value, host, path, expiry, lastAccessed, isSecure and isHttpOnly.

To get a list of cookies for a particular site, run a query like:
select * from moz_cookies
where host like '%stackoverflow%'



The cookie with the name usr, is all I wanted. Cloning that cookie in my other computer granted me access to my SO account. Simple or not, it works great ;-)

No comments:

Post a Comment