BBjThinClient::setUserProperty

Description

In BBj 11.0 and higher, this method stores a key/value pair in a specified client-side property group.

See below.

Syntax

Return Value

Method

void

setUserProperty(long group, string samesite, string key, string value)

void

setUserProperty(long group, string key, string value)

void

setUserProperty(string key, string value)

Parameters

Variable

Description

group

  • USER_PROPERTIES_COOKIES (0)

  • USER_PROPERTIES_STORAGE (1)

  • USER_PROPERTIES_SESSION (-1)

samesite

  • SAME_SITE_DEFAULT ("")

  • SAME_SITE_LAX ("Lax")

  • SAME_SITE_NONE ("None")

  • SAME_SITE_STRICT ("Strict")

key

Specifies the key to be saved on the client.

value

Specifies the value to be saved on the client.

Return Value

None.

Remarks

In BUI, USER_PROPERTIES_COOKIES maps to browser cookies with a 30-day expiration, USER_PROPERTIES_STORAGE maps to browser local storage, and USER_PROPERTIES_SESSION maps to browser session storage. Any other group value is treated as a cookie with a specified expiration timestamp (e.g. System.currentTimeMillis()+24*60*60*1000*7 is exactly 7 days from now).

In GUI, the three groups map to nodes in a Preferences tree.

If no group is specified, the default value is taken from STBL("!USER_PROPERTIES").

In BBj 20.0 and higher, the samesite value ("Lax", "None", or "Strict") can be specified  to control the set of domains that can read a given cookie. For more information, see Google's notes for Chrome 80+. If no samesite value is specified, the default value is taken from STBL("!SAME_SITE"). The samesite value is only meaningful in BUI.

Example 1

tc! = bbjapi().getThinClient()

tc!.setUserProperty("key","value")

print tc!.getUserProperty("key")  

Example 2

rem Save a user property and set the cookie's expiration date for 90 days
group = System.currentTimeMillis()+1000*60*60*24*90
BBjAPI().getThinClient().setUserProperty(group, "myKey","myValue")

rem Read in the saved property
savedValue$ = BBjAPI().getThinClient().getUserProperty("myKey")
print "The saved property 'myKey' has a value of '", savedValue$, "'"
end

See Also

BBjAPI

BBjThinClient

BBjThinClient::getUserProperty

BBjThinClient::getUserProperties

BBjThinClient::setUserProperties

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.



______________________________________________________________________________________

Copyright BASIS International Ltd. BBj®, Visual PRO/5®, PRO/5®, and BBx® are registered trademarks.