Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-03

Request redirection + login session in fpweb

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

leledumbo

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
Redirect the request back to its referer (I could get the referer from ARequest.Referer)

FYI, I've been able to login simply by using TtiObjectList.FindByProps.

If you need to see current code, it's attached.

http://free-pascal-general.1045716.n5.nabble.com/file/n5602126/tkd1depok.zip tkd1depok.zip

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Request-redirection-login-session-in-fpweb-tp5602126p5602126.html Sent from the Free Pascal - General mailing list .

Reply by email

Unknown author
to leledumbo
leledumbo wrote 7 lines
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.

Reply by email

leledumbo
to Unknown author: Save Session data in login request handler: Session.Variables['UserID']:='XYZ'; In every…

I've tried it out, but the session doesn't seem to be shared among modules, is it correct that I set CreateSession to true for all modules?

Please try the updated project (attached). The authentication is handled by ModAuth, but the login form (or welcome message + logout link) is handled by ModLayout. The login form would change to welcome message + logout link only if module in the uri stays in 'auth', where it's supposed to change as long as the session hasn't expired.

http://free-pascal-general.1045716.n5.nabble.com/file/n5604218/tkd1depok.zip tkd1depok.zip

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Request-redirection-login-session-in-fpweb-tp5602126p5604218.html Sent from the Free Pascal - General mailing list .

Reply by email