issue in webspeed

Srinivasa Rao

New Member
I have the following speed script code,

<html>
<head>
<TITLE>Search Customer</TITLE>
</head>
<body BGCOLOR="pink">
<FORM action="search.htm" method="post">
Enter Customer Number:<INPUT TYPE="text" NAME="custnum" />
<INPUT TYPE="submit" NAME="search" VALUE="search" />
</FORM>
<?ws>
DEFINE VARIABLE GET_val_txt AS CHARACTER NO-UNDO.
DEFINE VARIABLE GET_val_btn AS CHARACTER NO-UNDO.
DEFINE VARIABLE counter AS INTEGER NO-UNDO init 0.
GET_val_txt = get-value("custnum").
counter = int(get-cookie("cooki")).
{&out}
"<script language='javascript'>alert(" + string(counter) + ");</script>".
FIND FIRST customer WHERE cust-num = int(GET_val_txt) NO-ERROR.
IF AVAILABLE customer THEN
DO:
{&out}
"<form action='update.p' method='post'>"
"Customer Number : <input type='text' name='cust-num' value='" Cust-Num "' readonly /> <br />"
"Customer Name : <input type='text' name='custname' value='" NAME "' /> <br />"
"Phone Number : <input type='text' name='cust-phn' value='" phone "' /> <br />"
" <input type='submit' name='save' value='save' /> "
"</form>".
counter = counter + 1.
END.
ELSE IF not available customer and counter > 0 then
{&out} "<h2>No Record Found</h2>".
set-cookie("cooki",string(counter),?,?,?,?,?).
</?ws>
</body>
</html>

but in browser it appearing like

Set-Cookie: cooki=0; path=/scripts/cgiip.exe/WService=wsbroker1

i don't want to get above shown line.

what can i do for resolving it?
 

Marian EDU

Member
I have the following speed script code,

ELSE IF not available customer and counter > 0 then
{&out} "<h2>No Record Found</h2>".
set-cookie("cooki",string(counter),?,?,?,?,?).

there's your issue... a 'cookie' should be set in the header section, this means before any other output content is being sent. you might think that you can just change the order and put set-cookie before the {&out} line but that won't change anything since you're using a 'html' object that have already sent the 'set content type' line that actually close the header section, if you need to set a cookie you must do it in a 'cgi-wrapper' program.
 

Srinivasa Rao

New Member
Hi Marian,

Do you mean that i need to use .p or .w file for setting cookie??if not
Can you give me one example how to use 'cgi-wrapper' program.
 

Cecil

19+ years progress programming and still learning.
Try this.

Code:
<SCRIPT LANGUAGE="SpeedScript">
procedure output-headers:

DEFINE VARIABLE GET_val_txt AS CHARACTER NO-UNDO.
                 DEFINE VARIABLE GET_val_btn AS CHARACTER NO-UNDO.
                 DEFINE VARIABLE counter     AS INTEGER   NO-UNDO init 0.

                 GET_val_txt = get-value("custnum").
                 counter = int([B]get-cookie("cooki")[/B]).

counter = counter + 1.

[B]set-cookie("cooki",string(counter),?,?,?,?,?).[/B]

return.
End procedure.
</script>

<html>
    <head>
     <TITLE>Search Customer</TITLE>
    </head>
    <body BGCOLOR="pink">
        <FORM action="search.htm" method="post">
            Enter Customer Number:<INPUT TYPE="text" NAME="custnum" />
            <INPUT TYPE="submit" NAME="search" VALUE="search" />
        </FORM>

        {&OUT} "<script language='javascript'>alert(" + string(counter) + ");</script>".
                <?ws>

FIND FIRST customer WHERE cust-num = int(GET_val_txt) NO-ERROR.
                IF AVAILABLE customer THEN 
                DO:
                    {&out}
                        "<form action='update.p' method='post'>"
                            "Customer Number : <input type='text'    name='cust-num' value='" Cust-Num "' readonly />  <br />" 
                            "Customer Name   : <input type='text'    name='custname' value='" NAME     "' />           <br />"
                            "Phone Number    : <input type='text'    name='cust-phn' value='" phone    "' />           <br />"
                            "                  <input type='submit'  name='save'     value='save'         />                 "
                        "</form>".
                        
                END.
                ELSE IF not available customer and counter > 0 then
                {&out} "<h2>No Record Found</h2>".

        </?ws>        
    </body>
</html>
 
Top