This blog of mine might be helpful in understanding how it all works: http://blog.geekuni.com/2015/06/three-ways-to-implement-sessions.html