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,

有帮助吗?

解决方案

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top