Recent

Author Topic: fpWeb and sessions  (Read 722 times)

krolikbest

  • Full Member
  • ***
  • Posts: 246
fpWeb and sessions
« on: April 17, 2023, 09:43:16 pm »
Hi,
I would like to ask if is it current and proper way to use session like described in this topic: https://forum.lazarus.freepascal.org/index.php/topic,43256.msg302446.html#msg302446 ?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: fpWeb and sessions
« Reply #1 on: April 19, 2023, 12:00:40 pm »
Just checked, the last attachement still works as expected, so yes.

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: fpWeb and sessions
« Reply #2 on: April 19, 2023, 08:09:05 pm »
Thanks for checking. In the meantime, I realized my own idea for the sessions. In a nutshell, it involves using some sort of list, such as TStringList. There are stored so called session names (generated via Random procedure) when a new client (browser) logs into my http server. In few days I should show on my youtube some experiments with fphttpserver, pas2js, Raspberry Pi and esp8266 :)

egsuh

  • Hero Member
  • *****
  • Posts: 1292
Re: fpWeb and sessions
« Reply #3 on: April 20, 2023, 06:22:03 am »
HTTP Server may use TStringList for session management. But it's not portable to CGI model. Anyway I'm interested in your example.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: fpWeb and sessions
« Reply #4 on: April 20, 2023, 10:39:28 am »
The backend could be anything. Really the only connection a session has is its key cookie. Like egsuh said, though, TStringList won't survive one shot execution model employed by CGIs. Unless, you (Save|Load)FromFile accordingly. I usually just use Redis for session, as it has built-in expiration mechanism fully user controllable from query.
« Last Edit: April 22, 2023, 02:29:00 am by Leledumbo »

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: fpWeb and sessions
« Reply #5 on: April 20, 2023, 12:52:12 pm »
My solution is standalone httpserver working on Raspberry Pi. still I have some minor issues to configure RPi for working in to wifi subnets (RPi has two interfaces). One wifi is for working in range of my main home router, and second subnet is for working between RPi and few esp8266. Describing my problem with configuration of RPi is boring to read but i'm making some progress :)

 

TinyPortal © 2005-2018