0

What would be the correct way to implement session on G-WAN's Ruby, this is my idea:

  1. send a random cookie if not exists, or the GUID cookie would be fine? but how to read and write Cookie on G-WAN's Ruby? documentation only shows the examples on C
  2. create a file if not exists on /tmp/rubysessid-#{cookie_GUID} just like PHP did
  3. read the content on every request, and rewrite when changed

but the problem would be: 2 requests from the same source on the same time would rewrite cookie file content at the same time making it possible for data corruption or inconsistency

is there a better way to implement session on G-WAN's Ruby?

Gil
  • 3,279
  • 1
  • 15
  • 25
Kokizzu
  • 24,974
  • 37
  • 137
  • 233

1 Answers1

1

Web frameworks use databases or key-value stores (sometimes called dictionaries) to keep track of sessions.

I am not a Ruby developer but I guess that such features are available.

And G-WAN lets you access the HTTP request headers from Ruby (like from any other of the 15 programming languages), so there's really no problem to access the HTTP cookies.

The "documentation only shows the examples in C" because G-WAN was written in C with C scripts.

There, it made sense to fill a gap with a G-WAN API made for C/C++, etc.

That gap does not exist in Ruby and other scripted languages often used for Web development where people have plenty of choices to resolve those problems.

In the case of Ruby and others, G-WAN is not useful because of its API (CGI is used instead) but rather because of its speed and ease of use (among other things zero configuration comes to mind).

Gil
  • 3,279
  • 1
  • 15
  • 25