I am using sessions, and I redirect the from the login page to the main page if the user is registered. But I have a problem sometimes I can't log the user, so instead of redirecting the user using header('location: location.php'), I write a META tag and then redirect and give the page some time to create a session about 2 seconds. But still the problem does persist, And this happens only during the first time. Later everything works fine. And in the first time when i append the 'SID' to the page, The page url shows

location.phpPHPSESSID=5a8241c53dd904f3c16e31ab48798387

appended to the file. and then I get 404 error, If i remove the PHPSESSID part, The page works as expected, But for the first time why does it show on the URL? which causes error.

I think Pejone or some Moderator had written about this, and that is the reason I redirect using meta tag, but still...

Passing the Session IDThere are two methods to propagate a session id:

Cookies

URL parameter

The session module supports both methods. Cookies are optimal, but because they are not always available, we also provide an alternative way. The second method embeds the session id directly into URLs.

PHP is capable of transforming links transparently. Unless you are using PHP 4.2 or later, you need to enable it manually when building PHP. Under UNIX, pass --enable-trans-sid to configure. If this build option and the run-time option session.use_trans_sid are enabled, relative URIs will be changed to contain the session id automatically.

Alternatively, you can use the constant SID which is always defined. If the client did not send an appropriate session cookie, it has the form session_name=session_id. Otherwise, it expands to an empty string. Thus, you can embed it unconditionally into URLs.