콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
12586 화면

In Odoo 9.0 shop

I have a cookie in client side named products_per_page and I want to set it in session so I can use it in server side.

var session = require('web.session');
var utils = require(web.utils);
utils.set_cookie('product_per_page', 12);
// TODO: set in session

is it possible, or are there any other solution for this?


Thanks

아바타
취소
베스트 답변

With that code you will set the cookie on the client side, you don't need to set it on the session, it's setted on the browser related to the domain of your page. So you could simply do it like:

var utils = require(web.utils);

var ttl = 24*60*60*365;//time to live of the cookie

utils.set_cookie('product_per_page', 12, ttl);

Cookies of the page loaded domain will always be sended to the server by the browser and you could retrieve it on the server side like this:

from openerp.addons.web.http import request

...

ppp = request.httprequest.cookies.get('product_per_page', 20)

아바타
취소