fix possible bug in session keep.
Merge remote-tracking branch 'origin/4.0' into 4.0