moving user id fetch from session to before check for is logged in.