Symfony Session Timeout Annoyance…

Posted on April 25th, 2008 in Programming, symfony by mcnicholl

I have recently found that symfony doesn’t attempt to properly maintain the user’s session after logout.

This is a tad annoying as any attributes that have been set during a valid login session will still be set when the user is communicating with the server. It is also a security risk.

Symfony provides the basic building blocks for creating an application, and session management is a part of that. The myUser class contains paramter, attribute, credentials classes as well as some variables like culture (for internationalisation), authenticated and timedout.

The ‘authenticated’ variable’s use should be pretty obvious - when the application is processing the users login it should set the authenticated variable to ‘true’ :

$this->getUser()->setAuthenticated(true);

The ‘timedout’ variable is set automatically be symfony when … alas … the users session has expired/timed out - pretty self explanatory.

The problem comes when your application sets any parameters or attributes during the sessions lifetime. For example, in my application when the user logs in I set a session variable ‘nickname’ so that I can reference/identify the user during any subsequent requests :

$this->getUser()->setAttribute('nickname', $user->getNickname());

This is pretty basic and normal functionality.

This attribute should die along with the session, when it times out - but it doesn’t. There are some perfectly valid reasons why this happens e.g The ‘Validated User’ and the ‘Browsing User’ are two different things to the system but the contents of the shopping cart are not. Another example would be website tracking software. It monitors where users are and what they are looking at - a very good tool for marketing. This type of software doesn’t have to care whether the user is logged in order not as its only concern is where they are and what they are doing. This information needs session data to follow the user. If all session data were cleared after the user logged out - then the monitoring software would be thinking a new user arrived - which would be wrong.

What is needed in this situation is a trigger or a test that determines if the session has expired and if it has - then action something appropriately.

The only way that I have determined to do this is by editing the myUser.class.php file for the application (and every other application) in your project.

As the myUser class is instantiated before any actions we can alter/clean up the session before any proper processing is done :

class myUser extends sfBasicSecurityUser
{
  public function initialize($context, $parameters = array()) {
    parent::initialize($context, $parameters = array());
    if($this->isTimedOut()) {
      $this->getAttributeHolder()->remove('nickname');
    }
  }
}

If you don’t like the idea of having to do this for all your applications - then you can create a new class and make the myUser class extend it instead (you must ensure that the new class also extends sfBasicSecurityUser. That way you have one central place to update when you need to clean up your session.

Hope this helps…

If you have any better ways of doing this - please let me know. I’d be interested to hear your take on it.

Site Outage Is Now An Opportunity To Beg

Posted on April 13th, 2008 in General by mcnicholl

I never thought I’d see an opportunity for someone to outright beg when their website went down - but low and behold Tyler Cruz has managed it.

Posted on his site today is this :

Hello everyone, I apologize profusely for the site downtime (4 days now!). Unfortunately, one of my servers crashed and the data was wiped. I did have many backup solutions in place, but a series of unfortunate events occured (Murphy's Law). To make matters worse, the server crash occured right before I went on vacation - I am currently writing this on my laptop in he hotel room. We have recovered most of the data now, but there is one particular file that didn't get backed up which is vital. Unfortunately, it is on my home computer. Please be patient as I am working hard on getting my sites back up and running, and again, I apologize for the downtime. I have spent a lot of money on server upgrades and 911 emergency server administration costs, so if you'd like to donate something to help cover all the fees, I'd certainly appreciate it - any amount would be helpful. But please don't feel obligated to as I do make decent money from my websites. If you'd like to donate something, my PayPal address is: twcruz@hotmail.com - please put in the subject line "Server Donation". Thank you, and I hope to get everything back up and running ASAP! Cheers, Tyler Cruz Merendi Networks Inc.

(see attached image)

This plea comes from a man that supposedly, by his own admission, makes nearly $100, 000 per year. I find extra hillarity in the the sentence “But please don’t feel obligated to as I do make decent money from my websites.”. Who is he expecting will donate? I donate to charity but this is just pathetic idiocracy from a John Chow lap dog.

Get a backbone man.

Pathetic Begging

Top 5 MusicReviewZone.com Articles From March

Posted on April 8th, 2008 in MusicReviewZone.com, My Sites by mcnicholl

Every month from now on I am going to post the best articles from MusicReviewZone.com so that all the technology folks out there can take some time out from their relentless prototype, test, prototype lives and let some music into their brains.

The site is now 3 months old and got its first subscriber today! Yeh!

So here we have it - the Top 5 articles from MusicReviewZone.com for March :

  1. Gene Simmons Tells It Like It Is
  2. Winehouse’s Dad Plays Guilt Game
  3. Uh-Oh! Pete Doherty Is To Make An Anti-Drug Documentary…
  4. Hells Angels Couldn’t Kill Mick Jagger…
  5. Richie Sambora Arrested

Now this may seem like shameless plugging of an asset I own - and well - it is, but if I can’t support my own sites - then who else will?

MusicReviewZone.com is starting to have some Sitematch ads from Google being served - which is a good indication that the music market is a good one to get into. With the ongoing revolution in the industry at the moment, there will be an increasing need to advertise new albums, singles and downloadable material by bands needing to get a foothold and fan base away from the cosy arms of the record companies.

Most current music magazines and newpaper websites report the news. Straight - with no angles or personality. A more opinioned piece is what Music Review Zone offers.

Have you dropped by? What do you think?