exposed header on attempted 302 redirect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mm78
Forum Newbie
Posts: 1
Joined: Wed Oct 13, 2004 4:08 pm

exposed header on attempted 302 redirect

Post by mm78 »

twigletmac | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

I have a php login page, where the user enters name/psswd. The login credentials are accepted and validated just fine, then the browser attempts a 302 redirect. The code that is executed is below.

Code: Select all

if (strstr($_SERVER['SERVER_SOFTWARE'], "Microsoft-IIS"))
        header ("HTTP/1.0 302 Redirect");

      header ("Set-Cookie: site_userid=".$userid"; Max-age=86400; Version=1; Path=/");
      header ("Location: admin.php?action=admin_index");
However, the redirect doesn't occur, instead the http header info is just dumped out to the browser, so you end up on the same page it posted to, with the following header info exposed in the source.

Code: Select all

Status: 302 Content-type: text/html X-Powered-By: PHP/4.3.9 Set-Cookie: smg_site_userid=1_3a108dd950a9c96fdd9404a78d65a9ae; Max-age=86400; Version=1; Path=/ Location: admin.php?action=admin_index
And there is no cookie being set as the redirect is failing.

The confusing part is that all this code was working fine until some recent changes to the php version - the latest 4.3.9 was installed. This is running in a windows environment using IIS webserver.

Any ideas?? Thanks!
Post Reply