Sessions on PCs and Macs

David Eisinger, Development Director

Article Category: #Code

Posted on

When switching from Windows to a Mac, one thing that takes some getting used to is the difference between closing and quitting a program. On the Mac, as one Mac-Forums poster puts it, “To put it simply…you close windows. You quit applications.” Windows draws no such distinction — the application ends when its last window is closed. This may not seem like much of a difference, but it has serious potential ramifications when dealing with browsers and sessions; to quote the Ruby on Rails wiki:

You can control when the current session will expire by setting the :session_expires value with a Time object. If not set, the session will terminate when the user’s browser is closed.

In other words, if you use the session to persist information like login state, the user experience for an out-of-the-box Rails app is dramatically different depending on what operating system is used to access it (all IE jokes aside). I probably quit my browser three times a week, whereas I close all browser windows closer to three times an hour. Were I running Windows, this might not be an option.

On my two most recent projects, I’ve used Adam Salter’s Sliding Sessions plugin, which allows me to easily set the duration of the session during every request. This way, I can set the session to expire two weeks after the last request, independent of browser activity — a much saner default setup, in my opinion.

It’s well-known that Mac users are vastly over-represented among web developers, so I think there’s a distinct possibility that a silent majority of users are receiving a sub-optimal user experience in many Rails apps — and nobody really seems concerned.

David Eisinger

David is Viget's managing development director. From our Durham, NC, office, he builds high-quality, forward-thinking software for PUMA, the World Wildlife Fund, NFLPA, and many others.

More articles by David

Related Articles