Commit ea2e36bd authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2002-11-10 04:37:17 by cvscast] Empty log message

Original author: cvscast
Date: 2002-11-10 04:37:17+00:00
parent fdd444dc
(* TODO:
- correct error messages, not failwith "..."
- HTML design, logo
- dump
*)
open Netcgi
(* Configuration *)
let session_dir = "/home/frisch/sessions"
let timeout = 60 (* seconds *)
let max_sess = 5
let timeout = 60 * 5 (* seconds *)
let max_sess = 10
(*****************)
let persistant = ref false
let session_id = ref ""
......@@ -93,7 +104,11 @@ let main (cgi : Netcgi.std_activation) =
| `Open ->
if (nb_sessions >= max_sess) then
failwith "Too many open sessions ...";
gen_session_id ()
let sid = gen_session_id () in
(* touch the session file ... *)
let chan = open_out_bin (session_file sid) in
close_out chan;
sid
| `Close -> close_session (cgi # argument_value "session"); ""
| `New -> ""
| _ -> cgi # argument_value "session"
......@@ -114,10 +129,12 @@ let main (cgi : Netcgi.std_activation) =
if !persistant then (
try
let chan = open_in_bin (session_file !session_id) in
let s = Marshal.from_channel chan in
if in_channel_length chan > 0 then
(let s = Marshal.from_channel chan in
State.set s);
close_in chan;
State.set s;
with Sys_error _ -> ()
with Sys_error _ ->
failwith "This session has expired ..."
);
let ok = Cduce.run ppf input in
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment