Search in sources :

Example 1 with SessionCookieData

use of lucee.runtime.listener.SessionCookieData in project Lucee by lucee.

the class PageContextImpl method setClientCookies.

private void setClientCookies() {
    TimeSpan tsExpires = SessionCookieDataImpl.DEFAULT.getTimeout();
    String domain = PageContextUtil.getCookieDomain(this);
    boolean httpOnly = SessionCookieDataImpl.DEFAULT.isHttpOnly();
    boolean secure = SessionCookieDataImpl.DEFAULT.isSecure();
    ApplicationContext ac = getApplicationContext();
    if (ac instanceof ApplicationContextSupport) {
        ApplicationContextSupport acs = (ApplicationContextSupport) ac;
        SessionCookieData data = acs.getSessionCookie();
        if (data != null) {
            // expires
            TimeSpan ts = data.getTimeout();
            if (ts != null)
                tsExpires = ts;
            // httpOnly
            httpOnly = data.isHttpOnly();
            // secure
            secure = data.isSecure();
            // domain
            String tmp = data.getDomain();
            if (!StringUtil.isEmpty(tmp, true))
                domain = tmp.trim();
        }
    }
    int expires;
    long tmp = tsExpires.getSeconds();
    if (Integer.MAX_VALUE < tmp)
        expires = Integer.MAX_VALUE;
    else
        expires = (int) tmp;
    cookieScope().setCookieEL(KeyConstants._cfid, cfid, expires, secure, "/", domain, httpOnly, true, false);
    cookieScope().setCookieEL(KeyConstants._cftoken, cftoken, expires, secure, "/", domain, httpOnly, true, false);
}
Also used : TimeSpan(lucee.runtime.type.dt.TimeSpan) ApplicationContextSupport(lucee.runtime.listener.ApplicationContextSupport) ClassicApplicationContext(lucee.runtime.listener.ClassicApplicationContext) ApplicationContext(lucee.runtime.listener.ApplicationContext) SessionCookieData(lucee.runtime.listener.SessionCookieData)

Aggregations

ApplicationContext (lucee.runtime.listener.ApplicationContext)1 ApplicationContextSupport (lucee.runtime.listener.ApplicationContextSupport)1 ClassicApplicationContext (lucee.runtime.listener.ClassicApplicationContext)1 SessionCookieData (lucee.runtime.listener.SessionCookieData)1 TimeSpan (lucee.runtime.type.dt.TimeSpan)1