Why does is_user_logged_in() return false after redirect from another site?
Where are you triggering the second code block (that includes is_user_logged_in())? That code may be triggered before set_current_user, which is called after plugins_loaded. I would take a look at the action reference and see if you are calling your check before WordPress is aware of the user.