check session function in admin, removed repeating code