package ru.redguy.webinfomod.pages.logout; import fi.iki.elonen.NanoHTTPD; import ru.redguy.webinfomod.*; import ru.redguy.webinfomod.langs.Localization; import ru.redguy.webinfomod.utils.WebUtils; import java.io.IOException; @WebPage(url = "/logout") public class Index implements IWebPage { public NanoHTTPD.Response getPage(Config config, NanoHTTPD.IHTTPSession session) throws IOException { WebUtils.CookieHandler ch = new WebUtils.CookieHandler(session.getHeaders()); config.getLogger().info(LoggerType.Web,WebStatic.sessions.get(ch.read("session"))+ " has been logout!"); WebStatic.sessions.remove(ch.read("session")); ch.delete("session"); NanoHTTPD.Response response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.REDIRECT,NanoHTTPD.MIME_PLAINTEXT,""); response.addHeader("Location", "/"); ch.unloadQueue(response); return response; } }