I changed quite a lot of things to make this work, but first of all I guess i should explain about the site I'm using this on:
It's a "member site" with 2 choices at index.php : 1)create new users 2)log in existing user.
I used a plain html-form and set the action to login.php?switch=new for creating new users and login.php?switch=login for existing users.
In the login.php-file I made a switch-case with one case for "login" and one case for "new". If the login/new user data returned a failure, an errormessage was sent as a variable, the switch-case was "unset" and i included "index.php" once again.
After i changed my session-variable i was able to use the header-function as I tried to at first...
This may seem a bit confusing, but this is just a sketch of my solution.