Added session_expires check. Resolves #2344

I am not sure that I made it right, but please write if I am on the right way.