1

I came across the same problem as this with Safari rejecting the cookies and keep reloading the facebook iframe:

facebook app iframe login issue on safari

The solution in PHP should be something like this:

<?php
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"')
?>

I don't really understand PHP, how do I achieve this in Python/Flask? Do I have somehow to set this in every function in the view code or in base.html, which all other templates derive from?

Many Thanks,

Community
  • 1
  • 1
Houman
  • 64,245
  • 87
  • 278
  • 460

1 Answers1

0

Take a look at flask.make_response

"Sometimes it is necessary to set additional headers in a view. Because views do not have to return response objects but can return a value that is converted into a response object by Flask itself, it becomes tricky to add headers to it. This function can be called instead of using a return and you will get a response object which you can use to attach headers.

def index():
    response = make_response(render_template('index.html', foo=bar))
    # add your P3P header to the response
    response.headers['P3P] = 'xxxx'
    return response
codegeek
  • 32,236
  • 12
  • 63
  • 63
  • Many Thanks for the answer. While your solution works, it seems the P3P header solution is no longer a solution to the safari iframe problem. This answers my question but my search has to continue. – Houman Aug 06 '13 at 09:51
  • Just a followup question, how is this P3P code generated to solve the cross site cookie problem? I noticed this code is not always the same. Thanks – Houman Aug 06 '13 at 22:06