manage session and redirect