Consultor Eletrônico



Kbase P22145: How to GET and SET cookies in Webspeed
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/25/2003
Status: Unverified

GOAL:

How to SET, GET & Delete cookies in WebSpeed.

FIX:

Save this file "Example_cookie.html" in your WRK directory and compile it.
Then run it.


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<META NAME="AUTHOR" CONTENT="Alex Pearlstein">
<TITLE>WebSpeed Script</TITLE>
<SCRIPT LANGUAGE="SpeedScript">
/* Create an unnamed pool to store all the widgets created by this procedure.
This is a good default which assures that this procedure's triggers and
internal procedures will execute in this procedure's storage, and that
proper cleanup will occur on deletion of the procedure. */
CREATE WIDGET-POOL.
Define variable cookievar as c.


PROCEDURE Output-Header:
assign cookievar = get-value("cookievar").

CASE get-value("Button"):
WHEN "Get" THEN
get-cookie("testcookie").
WHEN "Set" THEN
set-cookie("testcookie":U, cookievar, ?, ?, ?, ?, ?).
WHEN "Delete" THEN
delete-cookie("testcookie", ?, ?).
END CASE.



End.


</SCRIPT>
</HEAD>

<BODY>
<Form method="Post" Name="cookieform" action="example_cookie.html">
<Center>
<input type="text" name="cookievar" value="` cookievar `">
<input type="submit" name="button" value="Set">
<input type="submit" name="button" value="Get">
<input type="submit" name="button" value="delete">
<BR>
</form>
This is a link to this same page
<BR><BR>
</Center>

The cookies current value is "<Font color=Green>` get-cookie("testcookie") `"</font> using the get-cookie() function <BR>
The action was <Font color=Green> "` get-value("Button") `" </font><BR>
The variable's current value is <Font color=Green> "` cookievar `" </font><BR>

<BR>


A cookie must make a round trip for the value to be looked at.<BR>
First by clicking on Set cookie we post the information to the server.<BR>
Then the returning page sets the cookie on the client.<Br>
After the cookie is set on the client machine, then it can be looked at by the server.<BR>
This Procedure <B>MUST</B> be in the HTML HEAD of the of the document<BR>


</BODY>


</HTML>