#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    71
    Rep Power
    11

    How to redirect a page with mime info


    Hi.
    Your help is highly appreciated.
    Im using apache server.
    Basically, I have a login page that authenticates a user.
    if the user was authenticated successfuly , then I want to send a cookie ( Session ID) and to redirect him to a new page.
    How can I do that?
    (
    ( 'Location...') works if there is no mime information...
    )

    It might sound a stupid question, but I can tell you I spent lots of time on that one..
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Mmmmm, you could try sending a meta refresh tag i.e.

    Code:
    <META HTTP-EQUIV=Refresh CONTENT="10; URL=http://www.address.com/">
    http://www.htmlhelp.com/reference/html40/head/meta.html

    If you've already sent all the headers, although i'm not seeing why you cant send the Cookie header followed by the Location header?

    This is a CGI project yes?

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    71
    Rep Power
    11
    Originally Posted by netytan
    Mmmmm, you could try sending a meta refresh tag i.e.

    Code:
    <META HTTP-EQUIV=Refresh CONTENT="10; URL=http://www.address.com/">
    http://www.htmlhelp.com/reference/html40/head/meta.html

    If you've already sent all the headers, although i'm not seeing why you cant send the Cookie header followed by the Location header?

    This is a CGI project yes?

    Mark.
    Hi Mark.
    If i'm sending the 'Location' after the header, then it doesn't work and
    the browser treats it like a plain text ( i mean, writing Location.....)
    This is so weared, it is such a basic functionality, and yet, it's looks like it is
    not very easy to implement
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    You can send more than one header at the same time as long as you dont have any blank lines since a blank like signals the end of the MIME header i.e.

    Code:
    MIME-Header
    MIME-Header
    MIME-Header
    MIME-Header
    
    Page-Content
    so...

    Code:
    #!/usr/bin/env python
    
    print 'Content-Type: text/html'
    print 'Location: http://www.python.org\n'
    Obvously these headers aren't very useful but it does demonstrate how to send more than one header to the browser.

    Let me know if this doesn't work for you.

    Mark.
    programming language development: www.netytan.com Hula

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    71
    Rep Power
    11
    Originally Posted by netytan
    You can send more than one header at the same time as long as you dont have any blank lines since a blank like signals the end of the MIME header i.e.

    Code:
    MIME-Header
    MIME-Header
    MIME-Header
    MIME-Header
    
    Page-Content
    so...

    Code:
    #!/usr/bin/env python
    
    print 'Content-Type: text/html'
    print 'Location: http://www.python.org\n'
    Obvously these headers aren't very useful but it does demonstrate how to send more than one header to the browser.

    Let me know if this doesn't work for you.

    Mark.
    Hi Mark, It doesn't work if I add cookies to the header,
    here's the exact code:

    Content-Type: text/html Set-Cookie: flare="FB187D1DD5L-270d9cf9"; Max-Age=3600; Version=1 Location: MenuGenerator.py?opMode=HomeMode
  10. #6
  11. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    You need a new line between each mime header. Give that a go...

    Content-Type: text/html
    Set-Cookie: flare="FB187D1DD5L-270d9cf9"; Max-Age=3600; Version=1
    Location: MenuGenerator.py?opMode=HomeMode

    Mark.
    programming language development: www.netytan.com Hula

  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    71
    Rep Power
    11
    Originally Posted by netytan
    You need a new line between each mime header. Give that a go...

    Content-Type: text/html
    Set-Cookie: flare="FB187D1DD5L-270d9cf9"; Max-Age=3600; Version=1
    Location: MenuGenerator.py?opMode=HomeMode

    Mark.
    Thanks Mark, it's working beautiful.
  14. #8
  15. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    No probs, happy to help ya out - knowledge is for sharing after all. Good luck with the app!

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo