[fpc-pascal] Request redirection + login session in fpweb

michael at freepascal.org michael at freepascal.org
Thu Mar 29 09:30:14 CEST 2012



On Wed, 28 Mar 2012, leledumbo wrote:

> I'm currently building a web app using HTTP server application project +
> fpweb + tiopf (with sqlite backend). However, I'm stuck in this scenario:
>
> Imagine a user log's in to my web app, which could be done from any page
> (it's part of the layout), how can I:
> Save login data in session, in case the login is successful, and reuse it in
> certain pages requiring login

Save Session data in login request handler:

Session.Variables['UserID']:='XYZ';

In every request that needs a login, do a

if (Session.Variables['UserID']='') then
    Response.SendRedirect('Yourloginurl');

> Redirect the request back to its referer (I could get the referer from
> ARequest.Referer)

Do something like this:

if LoginSuccesfull then
   begin
   Session.Variables['UserID']:='XYZ';
   Response.SendRedirect(ARequest.Referer);
   Exit;
   end;


Michael.



More information about the fpc-pascal mailing list