ceegeye sessions

The constructor for the xhtml class looks like this:

xhtml(const CGI& cgi, long SessionExpires = 3600, const string& Sessionfile = ".htceegisession");

 Notice the second parameter is the length of time a session will be kept (in seconds). The default being 1 hour (3600 seconds). So to get a shorter session time just construct an xhtml object thus:-

CGI cgi;
xhtml webpage(cgi, 5 * 60);
// 5 minutes

Notice the third parameter is the path to the session file for the cgi program in question. Each seperate cgi program can have a seperate session file. Most often you will probably want the same file for a number of cgi programs. Just put a file name constant in a header file somewhere and reference it in your constructors. e.g.

std::string sessionfile("/var/secretfolder/.htsessions"); 
CGI cgi;
xhtml webpage(cgi, 5 * 60, sessionfile);

Wherever the session file is the cgi program must be able to write to it so create an empty file and give your cgi programs write permissions. e.g.

me@server1:~$ touch /var/secretfolder/.htsessions
me@server1:~$ chown mywebserveruser /var/secretfolder/.htsessions
me@server1:~$ chmod 600 /var/secretfolder/.htsessions

To use the session object inside the xhtml object call it like this:

CGI cgi;
xhtml webpage(cgi);
webpage.session().set("variable1", "thevalue");

// later - or another run of the program or - another cgi. std::string variable1(webpage.session().get("variable1"));

The session variable contained in the xhtml object also has this interface:

// set the amount of time before the session expires. // e.g. to have the session expire in 1 day: settimeout(60 * 60 * 24); // This is a way to change the timeout after construction. void settimeout(long Expires);  // add/change a session variable. void set(const string& name, const string& value);  // return the contents of a session variable. // returns the empty string if the variable does not exist. string get(const string& name);  // remove a session variable. void remove(const string& name); 

Please see cgi_session.h for further details.