Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Peoplecode - how to create cookies?

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.

like image 786
VC1 Avatar asked May 29 '26 09:05

VC1


1 Answers

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

like image 122
Darryls99 Avatar answered Jun 01 '26 22:06

Darryls99



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!