Fix bug in setting session variables