Avoid using session variable directly

Use Session class instead.