set-cookie problem

akram

New Member
Hi All
When i am using the set-cookie function, a line is displayed to the screen showing the path to where the cookie was set. Here is the text visible on the top of the browser:

====================================================
Set-Cookie: testcookie=akram; path=/cgi-bin/web.sh
==========================================
Any Ideas on why this is displaying and how to get rid of this. Can someone help me to resolve this issue?

Thanks in advance!

Akram
 

rstanciu

Member
use "setCookie" always after "output-content-type"

{src/web2/wrap-cgi.i}
RUN SetCookie IN WEB-UTILITIES-HDL
("TEST", "1234", TODAY + 5,TIME, ?, ?, ?).
output-content-type ("text/html").
 

akram

New Member
Thanks for the repy! I have following code in output-header procedure. "output-content-type" is used
after set-cookie. Do you see any issue in the following code?

/*------------------------------------------------------------------------
Purpose: Output the MIME header, and any "cookie" information needed
by this procedure.
Parameters: <none>
Notes: In the event that this Web object is State-Aware, this is also
a good place to set the "Web-State" and "Web-Timeout"
attributes.
------------------------------------------------------------------------*/
/* We only perform the verify security cookie routine if the user has
logged on - as this function may be run from outside the application. */

IF get-cookie('testcookie') = "" THEN
set-cookie("testcookie","akram", ?, ?, ?, ?, ?).

IF get-value(ENCODE("UserID":U)) <> "":U THEN DO:
/*MESSAGE "checking session".*/
{psagent/getsess.i &xcRunHeader=Yes}.

END.

{pscommon/getcommn.i}
{psagent/preferen.i}
{psagent/ldfunfld.i &xcProcName="wwvehquote.w"}

lTravelAgent = (getUserType(gcUserId) = "TravelAgent":U).
IF lTravelAgent THEN
DO:

lHidePricePres = hidePricePres(gcUserID).
MESSAGE "lhidePrice" lHidePricePres.
END.
output-content-type ("text/html":U).

END PROCEDURE.
 

Marian EDU

Member
When i am using the set-cookie function, a line is displayed to the screen showing the path to where the cookie was set.

As Rares said, the reason is the output-content-type was already set which means the HTTP header section ended and now everything you send to the web-stream is going to made it into the page.

Among things you can check you can try to find out if:
- output-content-type might have been called in process-web-request
- run-web-object was used and the called object did set the content-type
- the web-object from which you are trying to set the cookie was called by other web-object at a point where the content-type was already set.
 

akram

New Member
Thanks every one for the response!

The issue is resolved. The problem was that set-cookie function was already used in the starting page of the application to set the cookie value for other cookies.

I set my new cookie on the same page and problem got resolved :)
 
Top