session logic begin