Skip to Content
author's profile photo Former Member
Former Member

Cookie parameters in .xsjs

Hi all

In my .xsjs file in a SAP HANA XS application, I want to create a cookie and send it to the browser. According to the SAP HANA XS JavaScript Reference, cookies are represented as name-value pairs (they are elements of a TupelList object).

The command

$.response.cookies.set('myCookieName', 'myCookieValue');

creates a cookie with the given name/value and sets the parameters 'host', 'path' and 'expires' automatically.

My question is: How can I modify e.g. the parameters 'path' and 'expires' ? Is it possible to do it in the .xsjs ?

Thanks

Christoph

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 17, 2013 at 02:54 PM

    Hi Christopher,

    If I am understanding your question right, here is your answer.

    $.session.getUsername() will directly give you the username from the cookie.

    You can then set it as response body and send it back.

    If you need something else plz reply back.

    Regards,

    Shubham Agrawal

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Shubham,

      I need something other than the username. Do you have any idea how to do that properly?

      I want to set some information related to the current session to the cookies, because I don't see any method in $.session that allows me to do that. But the problem comes to how to unset them (before the session end/logout)? I don't find any way to do this, and the JSDoc for XSJS has very little information on this.

      Thanks in advance.

  • author's profile photo Former Member
    Former Member
    Posted on Aug 18, 2016 at 11:47 AM

    Hi Christopher,

    Do you have an answer for this question now? Because I'm now looking for the same thing.

    To anyone else viewing this thread, do you know how to set the expires value for a cookie in XSJS? I need to set some custom information in key-value pairs in the cookies, but I cannot find a way to unset the cookies after they are used (and thus not needed any more).

    Thank you.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.