Hi ,
I am currently in an urgent need to create cookie from oracle BE and also read values from it . I have tried to use below code . its showing error
code
DECLARE
ourcookie owa_cookie.cookie;
BEGIN
ourCookie := owa_cookie.get('SESSION2');
END;
/

You write a cookie named SESSION. Then you read a cookie named SESSION2. And then you wonder why cookie SESSION2 does not exist. Think about it once again.

Btw. You can use your browser and check if the cookie is there. In firefox this under preferences=>Single cookies.
Not sure if I translated the menu option correctly. but since this was so urgent I didn't take the time to look it up.

Also this code needs to be run during the page load (onload page header).

842106 wrote:
Thanks all for your reply . Actually I need to create a fake cookie from oracle BE and try to retrieve values from it. I have modified my query and removed exceptions

Try to move the header_close procedure to the end of your routine and see if that changes anything.

owa_util.http_header_close;

If the cookie is not there you should get a no_data_found error.
But you got an numeric or value error. This indicates that something else went wrong.
I use the get function in apex from time to time. But only during the load of page headers. Not so sure if that is needed for the get function. It is necessary for the send however.

The problem could also be the path. Not sure if '/' is a valid path. Try to send without any path setting.

Cookies are send to the web browser, kept by the web browser, and supplied by the web browser.

In Apex, you can send a cookie to the web browser. And you can also read a cookie value from the web browser.

However, the Apex PL/SQL code that does this needs a valid web server CGI (Common Gateway Interface) environment. Details explained yesterday by me in posting {message:id=10649027}.

If you want to test your PL/SQL web enabled code outside of an Apex or mod_plsql environment, you need to create a valid OWA environment and manually create the cookies in this environment.

The details of how to write a web browser call (using PL/SQL) to a web enabled procedure is detailed in {message:id=2251131}.

Note that this approach requires that you create a PL/SQL call environment that supplies all the web browser details. This approach cannot be used to act like a real browser - and for example call a PL/SQL proc that sets a cookie, traps that call, and set the cookie. Or respond to an Ajax call. As a real web browser would do.

842106 wrote:
So is it not possible to create a real cookie and retrieve value from non apex or CGI environment ?

As Billy indicated.. cookies are related to web browsers. PL/SQL code within a database is not a web browser, so it has no concept of "cookie" storage. The cookie functionality provided by PL/SQL is to, in principle, communicate with the web browser to get it to create the cookie.

So is it not possible to create a real cookie and retrieve value from non apex or CGI environment ?

Yes it is. But the web browser is non-existant. So you need to create the CGI environment that the web server would have created, prior to calling your web enabled PL/SQL code.

So in other words, your CGI initialisation code needs to pretend it is the web server, it has received the web browser call, it has received the cookie(s) from the web browser - and now it needs to create the CGI environment (cookies included) for this web browser call, and then call the PL/SQL procedure that the web browser references in the URL it submitted.