fix some bugs in sessions helper