« Client-side image crop and then upload | Main | A proof from the mouth of a babe »

Gmail Autologout and Timed Session

gm-autologout.png

If your family is anything like ours, and your home is anything like ours, then you probably have one laptop per member on average, but everyone seems to prefer to use the "living room laptop" that's always sitting on the coffee-table. Thank Google for this - We don't really need to live down on earth any more, preferring instead the lofty locale of the clouds wherein most of our data resides.

The upside of this situation is that we are much more tolerant of individual computer crashes, since every machine to us is pretty much the same once we login. But the downside is that we invariably forget to log out of sessions in the common pool of machines we tend to use. This is normally no big deal, but the living room laptop tends to get used by our guests too. I have too often had to log out of private email sessions left open by our guests (as I hope my hosts will do for me in their homes :-)

To save time, worry and potential embarrassment, I've always wished that Gmail provided a configurable Autologout feature that users can turn on in their personal profiles. This would save them the trouble of having to remember whether they logged out of their sessions before they left for home.

Finding no such "Labs" feature and waiting all too patiently for it to appear, I eventually ended up writing my own (based on Chris Nguyen's cool Greasemonkey script for Searching Unread mail in Gmail). Because I have it on good authority from my friends at the big G that a full featured auto-logout will likely make its appearance in Gmail Labs sometime soon, I saved myself the trouble of embellishing the bare-bones functionality of this feature. But I find it useful, and hopefully so will you, until the official feature is released from the plex.

Here are the few really simple instructions on how to get a timed Gmail session with auto-logout within your browser. Oh, BTW, I implemented a Timed Session, rather than auto-logout based on inactivity - it's a quicker hack; I didn't have to listen for events and such.

To install Gmail Autologout, you first need to install the Greasemonkey plugin. I describe how to do it in Mozilla Firefox below. Installation in most other browsers is pretty simple and similar, if not pre-done for you.

Step 1 of 3: Install the Greasemonkey Firefox add-on. Greasemonkey allows you to simplify and automate a great many tasks using free scripts written by folks like us. I recommend that you install it. Get it from the official Mozilla add-ons page: https://addons.mozilla.org/en-us/firefox/addon/greasemonkey. Visit the page and click on the big green button that says "Add to Firefox":

greasemonkey-ff.png

Follow through with the rest of the steps. When you restart Firefox, you should see that Greasemonkey is active in the FF taskbar at the bottom right. Make sure the add-on is enabled by checking that the monkey is not grayed out. You can click on the monkey to toggle activation at any time during your Firefox session.

greasemonkey-status.png

You should also see a new menu item called Greasemonkey under "Tools" in the top menu, where you can selectively enable and disable specific scripts under "Manage User Scripts".

Step 2 of 3: Install my Gmail Autologout user script from userscripts.org. You can get it at http://userscripts.org/scripts/show/97613. If you forget the URL, search for "gmail autologout" on the userscripts.org site. Again, installation is a simple matter of clicking on the big green button that says "Install" and following through with the rest of the steps.

gm-us-install.png

That's it. If you login to your Gmail account now you should see a timer counting down (every 5 seconds, starting at 5 minutes). When it hits zero, you will be logged out of your gmail session (unless you have something unsaved, in which case you'll get a popup dialog).

Step 3 of 3: There's really no third step. But if you really want it, please go to
http://userscripts.org/scripts/show/97613 and become a fan of this script, or review it.

FAQ

Q. What if I have unsaved work? Will auto-logout make me lose it?

A. No. If you have unsaved work, Gmail will issue a popup confirmation dialog before logging you out. If you did actually get logged out, then your work was auto-saved and you can get right back to it from Drafts after logging back in. The trick I use when presented with this popup is to hit "Cancel" - telling Gmail that I don't want to logout. This, of course, silences Gmail for the moment, but the user script timer gives you just 5 more seconds before the next popup (if your work isn't auto-saved by then). To get another 5 whole minutes, simply save your work and refresh the Gmail page with Ctrl-R sometime within the 5-second window. It's like totally doable, I do it often :-)

Q. Can I get more than 5 minutes?

A. The short answer is "No." But if you can figure out a way to getElementByID of the text-input box that holds the countdown, inside of the timedSession() function, I'd appreciate knowing about your update to my script 'cos I'll be the first to use it. Note that you can always hit Ctrl-R in the Gmail window to refresh your 5-minute at any time.

Alternately, download a copy of the script (name it something that ends in .user.js), edit it locally to change the 5 minutes to your desired value and drag the re-saved script from your desktop into FF. The thing to change is the "value=300" attribute for the <input element near the bottom of the gm_autologout() function.

Q. Are there any caveats I should know about?

Yes - The script runs within the scope of Gmail only. If you login to your Google account outside of Gmail, or login to Gmail but close the tab without logging out, the script will not run and not log you out. Keep the Gmail session open.

Q. How can I prevent being auto-logged-out when I'm working on a Google Doc and have my Gmail tab open simultaneously?

A. The easiest way is to simply close the Gmail tab and open it if and when you want (you're already logged in, so there's little overhead). Or you can open a dummy popup chat window within Gmail and leave that open. After 5 minutes Gmail will issue a dialog asking if you want to logout because it will close that chat window, and you can leave that popup untouched until such time as you're really ready to logout. Hacky, but it works :-)

Note that you can remotely sign out of Google sessions from anywhere via the "Last Activity Link at the bottom of your Gmail page (see pic below).

gm-activity.png

Thus the feature I have provided is at best to set your mind at ease while on the road home.

Enjoy!

TrackBack

TrackBack URL for this entry:
http://www.pandamatak.com/cgi-bin/mt/mt-tb.cgi/76

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on February 24, 2011 6:53 AM.

The previous post in this blog was Client-side image crop and then upload.

The next post in this blog is A proof from the mouth of a babe.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.35