Meaningful Seaside Links after Session Expiry

There’s something about Seaside’s URLs that has bothered me for a long time, and I just discovered a solution. I haven’t seen anything about this anywhere else, so I figured I’d write it down in case it’s useful to anyone else.

Since your URLs are managed by your Seaside session, they all become invalid when your session times out. Leave your browser alone for a while, then return and click a link. Instead of taking you where it said it would, the link ends up taking you back to the first page of the app.

The well-known pattern for creating “bookmarkable URLs” is part of the solution here. You override #updateUrl: in your component, and then you override #initialRequest: in your root component or one of its children (i.e. something that’s visible by default). However, that only solves the problem of returning to your current page and has nothing to do with meaningful links on your current page after your session expires.

For most applications, this sort of behavior is not a big deal. Your session times out, you click something, and you’re kicked back to the “please sign in” page. Users tolerate this, because they’re used to the idea that their computer shouldn’t stay signed in forever.

But on a public area of a site, this sort of behavior really can get frustrating. I often pull up a page, get interrupted, and don’t get back to the page for several hours or days. The SqueakSource site has done this to me more than once. Browse to a SqueakSource page, go have lunch, and then come back and click a link. You get shown the homepage instead. Argh!

Thankfully, there are hooks in Seaside that make meaningful links possible. But they’re not very well known, and I can’t find any reference to them anywhere online. The methods are on WAAnchorTag, named #extraPath: and #extraParameters:. These two methods allow you to mangle the URL on the front side, just like you can with #updateUrl: on the other end.

You can use them like this:

(html anchor)
 callback: [self registerVolunteer];
 extraPath: 'volunteer';
 with: 'Become a Volunteer!'

If you’re already using the hooks for bookmarkable URLs, then it’s simply a matter of putting in the right path or parameters when you build the link.

It’s entirely possible to build meaningful URLs in Seaside. The tools are all there. And even though it seems harder than in other frameworks, it’s really not. It just feels hard, because Seaside gives you such a nice abstraction the rest of the time.

And if you’re building a content management system, you’ll likely be creating an abstraction that hides these details anyway.



Filed under Seaside

11 responses to “Meaningful Seaside Links after Session Expiry

  1. I’m glad to know that I wasn’t the only one who was frustrated whenever SqueakSource kicked me out to the main page.

  2. You know, it’s fairly simple to rig up a generic Ajax callback in your component base class that polls the server just under the timeout to prevent a session from ever expiring should someone leave the browser sitting. Just another way to avoid this problem. Nice find though.

  3. Ramon — that won’t really work, I’m afraid. One very typical case is folks shutting the lid on their macs for a few hours, and then opening them again. No AJAX while suspended I’m afraid.

  4. watt

    Well, the timeout is configured on server-side. Server should allow user’s session to linger for days or weeks, so – no timeouts.

  5. Philippe Marschall

    The problem with SqueakSource is not that we don’t know about these hooks, the problem is that it’s based on an old version of Seaside that doesn’t have them. In fact many of them were introduced as a result of SqueakSource. The reason why we aggressively time out sessions at SqueakSource is because we had several stability problems with the VM.

  6. @Brock, good point, I hadn’t considered suspend.

  7. Pingback: Seaside et REST « Talking Smalltalk

  8. Pingback: Talking Smalltalk » Blog Archive » Seaside et REST

  9. Pingback: Showing a “Session Expired” Notice in Seaside « Something to Talk About

  10. Is there an example of an application that uses all of these methods? Or an example code snippet somewhere?

  11. My friend on Orkut shared this link and I’m not dissapointed at all that I came to your blog.
    p.s. Year One is already on the Internet and you can watch it for free.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s