Consultor Eletrônico



Kbase 19822: Why a Set-Cookie Using a Variable Sets to Default Value
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/10/2008
Status: Verified

GOAL:

Why when passing a variable a Set-Cookie function Sets the viable to Default Value?

FACT(s) (Environment):

WebSpeed

FIX:

When you use the set-cookie function in Progress WebSpeed, when passing a variable, the cookie is set to the default value of the variable and not the value that you have assigned to it. The variable is set its value at the time that output-headers is run.

This occurs because the output-header (or output-headers depending on
the WebSpeed object type) is called from the include src/web/method/e4gl.i.
This include file is at the very beginning of any WebSpeed object type
(HTML mapped, HTML with embedded SpeedScript code, or CGI wrapper).

For example, for an HTML with embedded SpeedScript code, you can
compile the file and choose to save the temporary SpeedScript file.
You will then see the above mentioned reference to the include.
The following program illustrates this:

You need to run the program twice in order to see the cookies set, because a roundtrip will need to be done before the cookies are ailable on the server.

The example:
<html>
<head>
<title>Program to set up cookies</title>
<SCRIPT LANGUAGE=SpeedScript>
def var var1 as character no-undo.
def var var2 as character no-undo.

var1 = "This assign is done after output-headers is run".

Procedure output-headers:
var2 = "This assign is done within output-headers".
Set-cookie("var1", var1,?,?,?,?,?).
set-cookie("var2", var2,?,?,?,?,?).
end procedure.
</SCRIPT>
</head>
<body>
<SCRIPT LANGUAGE=SpeedScript>
{&OUT} 'Date and time: ' TODAY ' ' STRING(TIME, "HH:MM:SS").
{&OUT} '<BR>Cookie var1 is: : ' get-cookie("var1").
{&OUT} '<BR>Cookie var2 is: : ' get-cookie("var2").
</SCRIPT>
</body>
</html>