in reply to print and redirect

You don't have it all...
print "Status: 302 Moved Temporarily\n"; print "Location: $url\n\n";
If it still shows in your page then you are probably printing out headers and a \n\n somewhere above
                - Ant

Replies are listed 'Best First'.
Re: Re: print and redirect
by costas (Scribe) on Apr 10, 2001 at 18:30 UTC
    Ive realised where ive gone wrong, but its given me another problem.

    I am redirecting after i am creating a cookie. Since you can only write to a cookie once, does anyone know how i can write to a cookie and then immediately afterwards redirect to another page?

    Costas
      When I want to redirect a user I use the <meta> tag http-equiv=refresh - it's never given me any trouble. I would have your script write your cookie function and when it returns send the browser one of these:
      <meta http-equiv="refresh" content="0;url=http://redirect.url.here?anycgi=options&here=too">

      -Adam Stanley
      Nethosters, Inc.
        This works fine,

        However is it better coding practise for me to write the following?

        <html> <head> <meta http-equiv="refresh" content="0;url=http://redirect.url.here?any cgi=options&here=too"> </head> <body></body> </html>

        rather than just the meta refresh line

      I don't think you can write a cookie in a redirect, I've tried before... you have to use a http-equiv refresh
                      - Ant
        I don't know how you tried it, but it works fine for me... See node below for working example :)

        Greetz
        Beatnik
        ... Quidquid perl dictum sit, altum viditur.