我也想读到客户的一台厨师(在服务器上安装)。 我以第64号基调来处理这个问题,但也有少数小道子参与这种做法。
图1:64 显示线以0-2号等同标志告终,这些迹象正被转化成 75。 我的做法是将这些特点重新归为客户的同等性质。
2. 第64号基体在 co中被置于双重引号之上。 我删除这些内容。
服务器:
nav_json = json.dumps(nav_data)
nav_b64=base64.b64encode(nav_json)
self.response.set_cookie( nav_data , nav_b64)
Client:
var user_data_base64= $.cookie( nav_data );
// remove quotes from around the string
user_data_base64 = user_data_base64.replace(/"/g,"");
// replace 75 with =
user_data_base64 = user_data_base64.replace(/\075/g,"=");
var user_data_encoded=$.base64.decode( user_data_base64 );
var user_data = $.parseJSON(user_data_encoded);
I am using 2 jquery plugins here:
https://github.com/carlo/jquery-base64
and
https://github.com/carhartl/jquery-cookie
Note: I consider this a hack: It would be better to re-implement the python code that encodes the cookie in javascript, however this also has the downside that you would need to notice and port and changes to that code.
现在我已转向一种解决办法,即我使用一个小的html文档,把 co子放在客户一边,然后转到所要求的实际网页上。 这里是我使用的JINJA2模板的一个幻灯片:
<script type="text/javascript">
var nav_data= {% autoescape false %}{{nav_data}}{% endautoescape %} ;
$.cookie( nav_data , nav_data, { path: / });
window.location.replace("{{next}}")
</script>
Note 2: Cookies are not ideal for my use case and I will probably move on to Session or Local Storage to reduce network overhead (although my nav_data is quite small - a dozen characters or so.)