/* Licensed to the Apache Software Foundation (ASF) under one or more *contributorlicenseagreements.SeetheNOTICEfiledistributedwith *thisworkforadditionalinformationregardingcopyrightownership. *TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0 *(the"License");youmaynotusethisfileexceptincompliancewith *theLicense.YoumayobtainacopyoftheLicenseat * *http://www.apache.org/licenses/LICENSE-2.0 * *Unlessrequiredbyapplicablelaworagreedtoinwriting,software *distributedundertheLicenseisdistributedonan"ASIS"BASIS, *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. *SeetheLicenseforthespecificlanguagegoverningpermissionsand *limitationsundertheLicense.
*/
if (conf->selectlabel == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01853) "no SessionDBDselectlabel has been specified"); return APR_EGENERAL;
}
rv = dbd_init(r, conf->selectlabel, &dbd, &statement); if (rv) { return rv;
}
rv = apr_dbd_pvbselect(dbd->driver, r->pool, dbd->handle, &res, statement, 0, key, &expiry, NULL); if (rv) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01854) "query execution error saving session '%s' " "in database using query '%s': %s", key, conf->selectlabel,
apr_dbd_error(dbd->driver, dbd->handle, rv)); return APR_EGENERAL;
} for (rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1);
rv != -1;
rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1)) { if (rv != 0) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01855) "error retrieving results while saving '%s' " "in database using query '%s': %s", key, conf->selectlabel,
apr_dbd_error(dbd->driver, dbd->handle, rv)); return APR_EGENERAL;
} if (*val == NULL) {
*val = apr_pstrdup(p, apr_dbd_get_entry(dbd->driver, row, 0));
} /* we can't break out here or row won't get cleaned up */
}
if (conf->updatelabel == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01856) "no SessionDBDupdatelabel has been specified"); return APR_EGENERAL;
}
if (conf->insertlabel == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01858) "no SessionDBDinsertlabel has been specified"); return APR_EGENERAL;
}
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01860) "the session insert query did not cause any rows to be added " "to the database for session '%s', session not inserted", newkey);
if (conf->deletelabel == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01862) "no SessionDBDdeletelabel has been specified"); return APR_EGENERAL;
}
rv = dbd_init(r, conf->deletelabel, &dbd, &statement); if (rv != APR_SUCCESS) { /* No need to do additional error logging here, it has already
been done in dbd_init if needed */ return rv;
}
apr_status_t ret = APR_SUCCESS;
session_dbd_dir_conf *conf = ap_get_module_config(r->per_dir_config,
&session_dbd_module);
/* support anonymous sessions */ if (conf->name_set || conf->name2_set) { char *oldkey = NULL, *newkey = NULL;
/* if the session is new or changed, make a new session ID */ if (z->uuid) {
oldkey = apr_pcalloc(r->pool, APR_UUID_FORMATTED_LENGTH + 1);
apr_uuid_format(oldkey, z->uuid);
} if (z->dirty || !oldkey) {
z->uuid = apr_pcalloc(z->pool, sizeof(apr_uuid_t));
apr_uuid_get(z->uuid);
newkey = apr_pcalloc(r->pool, APR_UUID_FORMATTED_LENGTH + 1);
apr_uuid_format(newkey, z->uuid);
} else {
newkey = oldkey;
}
/* save the session with the uuid as key */ if (z->encoded && z->encoded[0]) {
ret = dbd_save(r, oldkey, newkey, z->encoded, z->expiry);
} else {
ret = dbd_remove(r, oldkey);
} if (ret != APR_SUCCESS) { return ret;
}
/* don't cache pages with a session */
apr_table_addn(r->headers_out, "Cache-Control", "no-cache, private");
if (r->user) {
ret = dbd_save(r, r->user, r->user, z->encoded, z->expiry); if (ret != APR_SUCCESS) { return ret;
} return OK;
} else {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01865) "peruser sessions can only be saved if a user is logged in, " "session not saved: %s", r->uri);
}
}
staticconst command_rec session_dbd_cmds[] =
{
AP_INIT_TAKE1("SessionDBDSelectLabel", ap_set_string_slot,
(void *) APR_OFFSETOF(session_dbd_dir_conf, selectlabel), RSRC_CONF|OR_AUTHCFG, "Query label used to select a new session"),
AP_INIT_TAKE1("SessionDBDInsertLabel", ap_set_string_slot,
(void *) APR_OFFSETOF(session_dbd_dir_conf, insertlabel), RSRC_CONF|OR_AUTHCFG, "Query label used to insert a new session"),
AP_INIT_TAKE1("SessionDBDUpdateLabel", ap_set_string_slot,
(void *) APR_OFFSETOF(session_dbd_dir_conf, updatelabel), RSRC_CONF|OR_AUTHCFG, "Query label used to update an existing session"),
AP_INIT_TAKE1("SessionDBDDeleteLabel", ap_set_string_slot,
(void *) APR_OFFSETOF(session_dbd_dir_conf, deletelabel), RSRC_CONF|OR_AUTHCFG, "Query label used to delete an existing session"),
AP_INIT_FLAG("SessionDBDPerUser", set_dbd_peruser, NULL, RSRC_CONF|OR_AUTHCFG, "Save the session per user"),
AP_INIT_FLAG("SessionDBDCookieRemove", set_dbd_cookie_remove, NULL, RSRC_CONF|OR_AUTHCFG, "Remove the session cookie after session load. On by default."),
AP_INIT_RAW_ARGS("SessionDBDCookieName", set_cookie_name, NULL, RSRC_CONF|OR_AUTHCFG, "The name of the RFC2109 cookie carrying the session key"),
AP_INIT_RAW_ARGS("SessionDBDCookieName2", set_cookie_name2, NULL, RSRC_CONF|OR_AUTHCFG, "The name of the RFC2965 cookie carrying the session key"),
{NULL}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.