Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » Please help with setting a cookie!
Please help with setting a cookie! [message #241769] Wed, 30 May 2007 10:30 Go to next message
lotusdeva
Messages: 198
Registered: March 2005
Senior Member
Ok, I have never done this, so I am totally lost Sad I basically have to set a cookie on a site and then redirect the user to a different app. This is how my cookie proc looks like:

PROCEDURE P_SetCookie IS
v_cookie owa_cookie.cookie;
v_uuid RAW(16);
BEGIN
--Call fun-n to get UUID (basically selects sys_guid()
-- from dual.
v_uuid := F_ReturnUUID();

v_cookie := owa_cookie.get('SSO_EFA');

--FALSE value in mime_header keeps the header open
--so we can insert the cookie into the header section
owa_util.mime_header('text/html', FALSE);

--This cookie will expire every 5 seconds --5/24/60/60
OWA_COOKIE.SEND('SSO_EFA',v_uuid, sysdate + 5/24/60/60
, '/', '.odu.edu');
owa_util.http_header_close;

htp.para;

htp.bold( 'Value of cookie ' || v_cookie.num_vals );

htp.para;

IF (v_cookie.num_vals > 0)
THEN
htp.bold( 'cookie is set and is ' || v_cookie.vals(1) );
ELSE
htp.p( 'cookie is not set' );
END IF;


END P_SetCookie;

I call this procedure b4 I do any logic on my page. The cookie does not get set, as I get "Cookie is not set" with a cookie value of 0. Also, for some reason I get the following printed on top of the page:

Content-type: text/html; charset=ISO-8859-1 Set-Cookie: SSO_EFA=31B27C9DF94663EBE0440000BEA958CA; expires=Wednesday, 30-May-2007 19:17:56 GMT; path=/; domain=.odu.edu;
Value of cookie 0


To me it looks like the cookie never gets into a header and maybe that is why it does not get set? I have no idea if this is even the problem or if it is, how to put it into the header. Please advise. Thank you!

Re: Please help with setting a cookie! [message #241851 is a reply to message #241769] Wed, 30 May 2007 13:46 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
See if this helps...

http://www.orafaq.com/forum/t/80747/0/

Hmmm... seems my code in the link is cut off. I'll have to look for the full code. Try a google on "owa_cookie.cookie get send remove"

[Updated on: Wed, 30 May 2007 14:01]

Report message to a moderator

Re: Please help with setting a cookie! [message #241861 is a reply to message #241851] Wed, 30 May 2007 14:36 Go to previous messageGo to next message
lotusdeva
Messages: 198
Registered: March 2005
Senior Member
Thank you! I got it to set the cookie. Except that on the top of my page I now get this:

Content-type: text/html; charset=ISO-8859-1 Set-Cookie:SESSIONID=.........

Do you by chance know how to get rid of this thing so that it does not show on the page?

Thank you!
Re: Please help with setting a cookie! [message #241894 is a reply to message #241861] Wed, 30 May 2007 19:27 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
the cookie needs to be handled at the right place in the HTML. You'll see that the headers are closed after setting. Try making sure that you use <HEAD>, <HTML> tags etc.
Previous Topic: closing parent window from child window thru PL/SQL
Next Topic: Problem in adding the User into Portal
Goto Forum:
  


Current Time: Sat Dec 10 22:46:46 CST 2016

Total time taken to generate the page: 0.15445 seconds