3

We are trying to create a cookie in the PeopleSoft Peoplecode by using the %Response object.

However, the code we tried is failing.

&YourCookie = %Response.AddCookie("YourCookieName", "LR");

Another snippet we tried to create the cookie

Local object &Response = %Response;
Local object &YourCookie;
&YourCookie = &Response.CreateCookie("YourCookieName");
&YourCookie.Domain = %Request.AuthTokenDomain;
&YourCookie.MaxAge = -1; /* Makes this a session cookie (default) */
&YourCookie.Path = "/";
&YourCookie.Secure = True; /* Set to true if using https (will still work with http) */
&YourCookie.Value = "Set the cookie value here. Encrypt sensitive information.";

The document reference points to IScript functions called CreateCookie methods etc. http://docs.oracle.com/cd/E15645_01/pt850pbr0/eng/psbooks/tpcr/chapter.htm?File=tpcr/htm/tpcr21.htm

However, these don't work in Peoplecode. We don't have the knowledge to create IScript or use it. Any insight with the People code API for cookies or IScript is much appreciated.

VC1
  • 1,660
  • 4
  • 25
  • 42

2 Answers2

1

I just tested on PeopleTools 8.54.11 and was able to create a cookie using the snippet you provided above.

I did find I had an issue if I set

&YourCookie.Secure = True; 

in an environment where I was using HTTP.

If you set Secure to False the cookie will be available in both HTTP and HTTPS

if you set Secure to True the cookie is only available in HTTPS

PeopleTools 8.54 Documentation showing the CreateCookie method

Darryls99
  • 921
  • 6
  • 11
1

I have been trying to do this (same code snippet) from within signon peoplecode, tools release is 8.54.09. I can execute the first two lines of code, but as soon as the line of code executing the CreateCookie() method executes, I get tossed out / end up on the signon error page.

This seems to support the previous answer saying that the API has removed the method, but the answer before that says it has been successful on tools 8.54.11 -- does that mean they removed it, then put it back, and I happen to be stuck with a release where it was removed? :-/

Anne
  • 11
  • 1
  • 1
    Signon peoplecode does not have access to the %request or the %response object and therefore you cannot set a cookie from within signon peoplecode. – Darryls99 Nov 20 '15 at 16:48
  • Thanks @Darryls99 - that explains our issue as well. We were trying to set the cookie in the Signon peoplecode as well. – VC1 Dec 02 '15 at 16:09