fix possible bug in session keep.
Merge branch '4.0'