Commit 252cdbb0dc074162c24764911f78637d649e0610

Authored by Georg Hopp
1 parent e69a4962

now it works mostly as before...the only difference is that you really have to b…

…e logged in to see the rand value
... ... @@ -4,7 +4,7 @@
4 4 * \author Georg Hopp
5 5 *
6 6 * \copyright
7   - * Copyright © 2012 Georg Hopp
  7 + * Copyright © 2013 Georg Hopp
8 8 *
9 9 * This program is free software: you can redistribute it and/or modify
10 10 * it under the terms of the GNU General Public License as published by
... ... @@ -22,6 +22,7 @@
22 22
23 23 #define _GNU_SOURCE
24 24
  25 +#include <time.h>
25 26 #include <stdio.h>
26 27 #include <stdlib.h>
27 28 #include <sys/types.h>
... ... @@ -121,8 +122,18 @@ void
121 122 applicationAdapterHttpUpdate(void * _this, void * subject)
122 123 {
123 124 ApplicationAdapterHttp this = _this;
124   - HttpWorker worker = (HttpWorker)subject;
125   - unsigned long sid = getSessionId(worker->current_request->cookies);
  125 + HttpWorker worker = (HttpWorker)subject;
  126 + unsigned long sid = getSessionId(worker->current_request->cookies);
  127 + Session session = applicationSessionGet(this->application, sid);
  128 +
  129 + if (NULL != session) {
  130 + if (time(NULL) < session->livetime) {
  131 + session->livetime = time(NULL) + SESSION_LIVETIME;
  132 + } else {
  133 + applicationSessionStop(this->application, sid);
  134 + }
  135 +
  136 + }
126 137
127 138 if (0 == strcmp("POST", worker->current_request->method)) {
128 139 if (0 == strcmp("/login/", worker->current_request->path)) {
... ...
... ... @@ -35,7 +35,8 @@
35 35 void
36 36 applicationSessionStop(Application this, unsigned long sid)
37 37 {
38   - hashDeleteByVal(this->active_sessions, sid);
  38 + Session session = hashDeleteByVal(this->active_sessions, sid);
  39 + delete(session);
39 40 }
40 41
41 42 // vim: set ts=4 sw=4:
... ...
Please register or login to post a comment