简体   繁体   中英

How can I get session variable that is set in flask?

I am trying to get a session variable that was set in flask but it doesn't work.

This is the server side:

session["user_request"] = search_request
print (session["user_request"])

This is the client side:

var user_request = '<%=Session["user_request"]%>';
alert(user_request);

I expect it to print the data given to it but it prints: <%=Session["user_request"]%>

Python Code:-

session['data'] = 'data'

JS Code

var data = {{ session['data'] }}
console.log(data) 

^^ (Case sensitive and spaces are mandatory)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM