Reading cookies from within Mendix

Is it possible (and how) to read cookies from within Mendix?
3 answers

Not in the 'normal' DSLs, unfortunately. However, if you do add your own RequestHandler (via Core.addRequestHandler) you can serve custom URLs (such as http://localhost:8080/herman/)

The requesthandlers receive MxRuntimeRequest which contain a method getOriginalRequest, which will in turn give you the original HttpRequest. You should be able to read cookies from the request if you cast it to the appropriate class first.


Update here since this thread got dug up anyway: Since Mendix 7.12, you can access the request and response objects in a request and read/write cookies if necessary. Per the release notes:


  • We enabled access to low-level request and response objects via IContext.getRuntimeRequest() and IContext.getRuntimeResponse() in custom Java actions in order to allow for the customization of the response (for example, adding a custom header, cookie, etc.).

I do not fully agree with Achiel. Serverside: yes, but you could also read/write cookies Clientside using javascript. So you could build a widget to read/write cookies: