Session controller rewritten