mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 00:58:32 -04:00
- Adapt server code for QtWebapp namespace 'stefanfrings' - Implement custom modifications needed by v1 controller via template engine - Unify iphone and ipad templates
35 lines
987 B
C++
35 lines
987 B
C++
/**
|
|
@file
|
|
@author Stefan Frings
|
|
*/
|
|
|
|
#include "sessioncontroller.h"
|
|
#include "../static.h"
|
|
#include <QVariant>
|
|
#include <QDateTime>
|
|
|
|
using stefanfrings::HttpRequest;
|
|
using stefanfrings::HttpResponse;
|
|
|
|
SessionController::SessionController() { }
|
|
|
|
void SessionController::service(HttpRequest &request, HttpResponse &response)
|
|
{
|
|
|
|
response.setHeader("Content-Type", "text/html; charset=ISO-8859-1");
|
|
|
|
// Get current session, or create a new one
|
|
HttpSession session = Static::sessionStore->getSession(request, response);
|
|
if (!session.contains("startTime")) {
|
|
response.write("<html><body>New session started. Reload this page now.</body></html>");
|
|
session.set("startTime", QDateTime::currentDateTime());
|
|
}
|
|
|
|
else {
|
|
QDateTime startTime = session.get("startTime").toDateTime();
|
|
response.write("<html><body>Your session started ");
|
|
response.write(startTime.toString().toLatin1());
|
|
response.write("</body></html>");
|
|
}
|
|
}
|