The issue I am running into is that when I try to go to a course URL using header("location:[moodleurl]/course/view.php?id=[courseid]) after clearing all of my browser data I am redirected to the Moodle home page, but not into the course. If I log out and then log back in without closing the browser I am redirected into the course. If I delete all of the Moodle and Drupal cookies, it still redirects me to the course. It is only if I clear all of my browser history and restart the browser that I am redirected to the Moodle home page.
The behavior indicates to me that some data, other than cookies, is being stored in the browser which is determining if I am redirected to the home page or the course. Any ideas, besides the Moodle session cookie, what data is set in a browser when a user logs in?