Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Session variable wanted

Re: Session variable wanted

From: Vladimir M. Zakharychev <bob_at_dpsp-yes.com>
Date: Wed, 5 Mar 2003 19:16:18 +0300
Message-ID: <b457u9$5tf$1@babylon.agtel.net>


HTTP is discrete by design (if we do not delve deep into Keep-Alive.) Thus, it is up to the developer to preserve application state between HTTP calls. HTTP cookies were introduced to help developers with that. The idea is simple: the application saves its state in some permanent storage (a table, for example) on the server and assigns this state a unique identifier (session id), and sends this identifier to the HTTP client in a cookie. On subsequent requests, the client presents this identifier to the server as part of the request. The application starts clean, retrieves stored session state associated with the session id it got from the client, and reinitializes the application to that saved state. From now on, it can proceed as there was no interruption in its flow. If you do not like cookies, you can implement similar mechanism manually: just include the data you want to be preserved between calls in HTML forms (as hidden parameters, for example.) On the next request, the client will send this data as part of the request.

Having said that, it's not possible to use package variables as permanent storage for session data - packages are reset between HTTP calls (some versions of mod_plsql supported "stateful" applications, where packages were not reset between calls, but this approach was abandoned because it forced to maintain separate Oracle session for each HTTP session, which was not particularly good idea since the HTTP client may terminate without notifying the server it did, leaving associated Oracle session stranded.) Stateless mode requires the application to preserve state between calls if needed.

OWA supports setting and retrieving cookies through OWA_COOKIE package. How you will preserve the application state is up to you anyway.

hth.

-- 
Vladimir Zakharychev (bob@dpsp-yes.com)                http://www.dpsp-yes.com
Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications.
All opinions are mine and do not necessarily go in line with those of my employer.


"Pavel Vetesnik" <Pavel.Vet_at_volny.cz> wrote in message news:b44jfr$kju$1_at_ns.felk.cvut.cz...

> Hello,
>
> I want to write an application using PL/SQL (with Oracle 8 installed), where
> user will access data using HTML interface.
>
> What I am looking for is an variable, that will be kept during whole users
> session. I thought, that variables defined for whole package will do the
> task, but they probably do not.
>
> I created a little testing application, which you may find at
> http://newalex.stk.cz:7777/pls/portal30/el_cas.testovaci.showpage1 . There
> are 2 procedures (1st page and 2nd page) and I want to keep is a variable
> set in the 1st page.
>
> The source code follows. Any help is appreciated.
>
> Thank you in advance,
> Pavel
> --------------------------------------------------------------------------
> CREATE OR REPLACE PACKAGE testovaci IS
> cTitle VARCHAR2(100);
>
> PROCEDURE showpage1;
> PROCEDURE showpage2;
> END;
> /
>
> CREATE OR REPLACE PACKAGE BODY testovaci IS
>
> PROCEDURE showpage1 IS
> BEGIN
> cTitle:='This is the text I want to keep...';
> htp.htmlopen;
> htp.bodyopen;
> htp.header(1, ctitle);
> htp.p('<a
> HREF="http://newalex.stk.cz:7777/pls/portal30/el_cas.testovaci.showpage2">Cl
> ick for page2</a>');
> htp.bodyclose;
> htp.htmlclose;
> END;
>
> PROCEDURE showpage2 IS
> BEGIN
> htp.htmlopen;
> htp.bodyopen;
> htp.header(1, cTitle);
> htp.p('If you can see "This is the text I want to keep..." above
> this line, then everything works fine. If this is the only line on the page,
> then it doesn''t work.');
> htp.bodyclose;
> htp.htmlclose;
> END;
> END testovaci;
> /
>
> GRANT EXECUTE ON testovaci TO PUBLIC;
> --------------------------------------------------------------------------
>
>
Received on Wed Mar 05 2003 - 10:16:18 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US