CODECUBE VENTURES

Avoid Unneeded Sessions

In my previous article on "alternative" web services. I showed you how you can share information across websites. Here's a small pitfall that's easy to avoid.

Since the browser thinks it's requesting a javascript file, it will put an HTTP get request to the site where the file resides. The web server serving the file will see it as a regular request, and begin a session for that request. This may inadvertently skew site stats (if you keep track of those things ;-) ) because the server will start a session with the calling page as the referer, even though the person viewing that page may not even know of your site's existence.

This is even worse if you happen to run two different sites on the same server that are sharing information. That means that for every user, two sessions will be started on the same machine. I recently came across this issue when we launched the TODCON MX site. It is sharing a news feed from the MX inSite Magazine site. All of a sudden, we began to see all these sessions with todcon.org as the referring page. It wasn't too bad because we caught it before todcon started getting a lot of hits. But if gone unnoticed, it might be disastrous depending on the traffic the sites generate.

To avoid this issue, you can easily stop that page from starting a session by adding this at the top:

<%@ page EnableSessionState="false" %>

This is true for both asp, and asp.net.

Hope that helps someone.

Latest post: Digging Up the First Version of CodeCube

See more in the archives