Forum Discussion
QWERTY
14 years agoOccasional Contributor
A bit more specifics on the full script:
The filterRequest method first calls the getEndpointType method to resolve the type of cookie to be used. It then enters a switch based on the result. Each case sets the type and cookie and then calls the populateHeader method. This one is a bit more complicated. Basically it checks if a header even exists and if so, if the key is "cookie" (ignores case) and if the current cookie the same. If so, nothing happens otherwise the cookie is updated. If no header exists one is added and if the value of the cookie (in the script file) is empty, the log informs the user and nothing happens.
Now, the header read from the request includes "Cookie : " which is removed by using substring(9) and a line break at the end that is removed by replaceAll("(\\r|\\n)
The key is a property used in the replace and put methods belonging to the StringToStringMap class. Look it up in the API for details.
This script, unlike the lite version, will not work out of the box but needs a bit of configuring but read through it and you'll understand the principle.
The filterRequest method first calls the getEndpointType method to resolve the type of cookie to be used. It then enters a switch based on the result. Each case sets the type and cookie and then calls the populateHeader method. This one is a bit more complicated. Basically it checks if a header even exists and if so, if the key is "cookie" (ignores case) and if the current cookie the same. If so, nothing happens otherwise the cookie is updated. If no header exists one is added and if the value of the cookie (in the script file) is empty, the log informs the user and nothing happens.
Now, the header read from the request includes "Cookie : " which is removed by using substring(9) and a line break at the end that is removed by replaceAll("(\\r|\\n)
The key is a property used in the replace and put methods belonging to the StringToStringMap class. Look it up in the API for details.
This script, unlike the lite version, will not work out of the box but needs a bit of configuring but read through it and you'll understand the principle.