..... what's the error?

If it's something to do with sessions, you will need to put session_start() at the top of your code, or else your session information will not be visible.