in reply to [CGI] redirect after headers have been printed

      "The problems is, to set the session variables I need to print the HTTP header first."

Why do you need to do that ?

Logically, you are either giving the user output, or redirecting him.
If the user needs to be fed some information in response to the form, you can get the receiving (redirected) page to display that information, by passing that information either as a session variable, or via a querystring.

In the absolutely last resort, you can output a page to the client, then use client-side refresh to redirect the page.

     "For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken

  • Comment on Re: [CGI] redirect after headers have been printed

Replies are listed 'Best First'.
Re^2: [CGI] redirect after headers have been printed
by jhourcle (Prior) on Jul 14, 2006 at 02:47 UTC
    Why do you need to do that ?

    Simple -- you have a website that uses cookies for authentication. It senses someone's not logged in, and sends them to a login form. The form submits to a page -- that sets the necessary cookies, and then redirects them back to the page they originally attempted to access.

    Yes, there are other ways of doing this, but when the majority of your pages and other items (images, video, etc.) are static, it doesn't make sense to place the whole thing between a heavyweight CMS.

    Yes, this might be an XY Problem, but I've had the same problem before, when tool authors assume that this feature would never be needed, and yet it makes perfect sense to me.