added some logic for session controls.
This commit is contained in:
parent
92d34ee689
commit
ce6b163d5d
1
Global.h
1
Global.h
@ -32,6 +32,7 @@ namespace jet {
|
|||||||
std::map<coreutils::MString, coreutils::MString> tags;
|
std::map<coreutils::MString, coreutils::MString> tags;
|
||||||
char **envp;
|
char **envp;
|
||||||
bool cgi = false;
|
bool cgi = false;
|
||||||
|
bool session = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
19
__jet.cpp
19
__jet.cpp
@ -9,14 +9,31 @@ namespace jet {
|
|||||||
if(keywordDefined("cgi") && (resolveKeyword("cgi") == "true")) {
|
if(keywordDefined("cgi") && (resolveKeyword("cgi") == "true")) {
|
||||||
global.cgi = true;
|
global.cgi = true;
|
||||||
|
|
||||||
if(keywordDefined("sessiondir")) {
|
cookies = getenv("HTTP_COOKIE");
|
||||||
|
|
||||||
|
if(keywordDefined("sessiondir")) {
|
||||||
|
global.session = true;
|
||||||
// if request_has_cookie then
|
// if request_has_cookie then
|
||||||
// pull sessionfile from sessiondir.
|
// pull sessionfile from sessiondir.
|
||||||
|
// if last activity time is expired then ignore.
|
||||||
|
// follow sessiontimeoutredirecturl.
|
||||||
// else
|
// else
|
||||||
// generate new session id.
|
// generate new session id.
|
||||||
// create session cookie in response.
|
// create session cookie in response.
|
||||||
|
char hashit[64];
|
||||||
|
char hash[32];
|
||||||
|
sprintf(hashit, "JETSESSION%ld", time(0));
|
||||||
|
SHA1(hashit, strlen(hashit), hash);
|
||||||
|
sprintf(hashname, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
||||||
|
hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7], hash[8], hash[9],
|
||||||
|
hash[10], hash[11], hash[12], hash[13], hash[14], hash[15], hash[16], hash[17], hash[18], hash[19]);
|
||||||
|
coreutils::ZString sessionCookie(hash);
|
||||||
|
global.headers[keywords["Set-Cookie"]] << "session=" << sessionCookie;
|
||||||
|
if(keywordDefined("sessiontimeout")) {
|
||||||
|
time_t timeout = time(0) + keywords["sessiontimeout"].asInteger();
|
||||||
|
}
|
||||||
|
|
||||||
|
// also save last activity time in session file.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user