Kbase 17305: How to Use Cookies (set-cookie) in WebSpeed
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/15/2008 |
|
Status: Verified
GOAL:
How to use cookies (set-cookie) in WebSpeed?
GOAL:
How to use "set-cookie" in WebSpeed?
FACT(s) (Environment):
WebSpeed 2.x.
WebSpeed 3.x
FIX:
Netscape's client side defines cookies as a general mechanism that server-side connections can use to both store and retrieve information on the client side of the connection.
The use of cookies involves the concept of a round trip in order to be accessible. In other words, once a cookie has been set, there has to be browser interaction before the cookie is available to be used. Once the cookie becomes available, it can be accesses by any request from that browser to a subsequent Web object.
Cookies store information as part of the HTTP header. Consequently, you must set cookies and delete cookies in the output-header procedure of a web object by use of the set-cookie and delete-cookie functions.
Mapped HTML web objects provide a standard output-header procedure complete with sample code for setting a cookie. When you use embedded SpeedScript, you must create an output-header procedure yourself.
The following code is an example of running a web object (getcookie.r) on the POST of another web object (cookie,r). The POST indicates that the submit button has been pressed, that the html has been already viewed:
/* Cookie.htm */
<html>
<head>
<title>This is where the cookie is set:</title>
<SCRIPT LANGUAGE=SpeedScript>
Procedure output-headers:
set-cookie("Test","This_is_the_cookie_value",?,?,?,?,?).
end procedure.
</script>
</head>
<body>
<form action="getcookie.r" method="POST">
<p>This is a test for setting a cookie:
<p><input type="submit" name="B1" value="Submit"></p>
</form>
</body>
</html>
The getcookie.r is a cgi wrapper procedure with the following code
added to the process-web-request section:
{&OUT} "get the cookie value here:" get-value("Test").