Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
12532 Weergaven

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

Avatar
Annuleer
Beste antwoord

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)

Avatar
Annuleer