PHP_FE(session_module_name, NULL)
PHP_FE(session_save_path, NULL)
PHP_FE(session_id, NULL)
+ PHP_FE(session_regenerate_id, NULL)
PHP_FE(session_decode, NULL)
PHP_FE(session_register, NULL)
PHP_FE(session_unregister, NULL)
convert_to_string((*ppid)); \
PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRLEN_PP(ppid))
+static void php_session_reset_id(TSRMLS_D)
+{
+ int module_number = PS(module_number);
+
+ if (PS(send_cookie)) {
+ php_session_send_cookie(TSRMLS_C);
+ }
+
+ /* if the SID constant exists, destroy it. */
+ zend_hash_del(EG(zend_constants), "sid", sizeof("sid"));
+
+ if (PS(define_sid)) {
+ smart_str var = {0};
+
+ smart_str_appends(&var, PS(session_name));
+ smart_str_appendc(&var, '=');
+ smart_str_appends(&var, PS(id));
+ smart_str_0(&var);
+ REGISTER_STRINGL_CONSTANT("SID", var.c, var.len, 0);
+ } else {
+ REGISTER_STRINGL_CONSTANT("SID", empty_string, 0, 0);
+ }
+
+ if (PS(apply_trans_sid)) {
+ php_url_scanner_reset_vars(TSRMLS_C);
+ php_url_scanner_add_var(PS(session_name), strlen(PS(session_name)), PS(id), strlen(PS(id)), 1 TSRMLS_CC);
+ }
+}
+
PHPAPI void php_session_start(TSRMLS_D)
{
zval **ppid;
zval **data;
char *p;
- int send_cookie = 1;
- int define_sid = 1;
- int module_number = PS(module_number);
int nrand;
int lensess;
PS(apply_trans_sid) = PS(use_trans_sid);
+ PS(define_sid) = 1;
+ PS(send_cookie) = 1;
if (PS(session_status) != php_session_none)
return;
lensess + 1, (void **) &ppid) == SUCCESS) {
PPID2SID;
PS(apply_trans_sid) = 0;
- send_cookie = 0;
- define_sid = 0;
+ PS(send_cookie) = 0;
+ PS(define_sid) = 0;
}
if (!PS(use_only_cookies) && !PS(id) &&
zend_hash_find(Z_ARRVAL_PP(data), PS(session_name),
lensess + 1, (void **) &ppid) == SUCCESS) {
PPID2SID;
- send_cookie = 0;
+ PS(send_cookie) = 0;
}
if (!PS(use_only_cookies) && !PS(id) &&
zend_hash_find(Z_ARRVAL_PP(data), PS(session_name),
lensess + 1, (void **) &ppid) == SUCCESS) {
PPID2SID;
- send_cookie = 0;
+ PS(send_cookie) = 0;
}
}
strstr(Z_STRVAL_PP(data), PS(extern_referer_chk)) == NULL) {
efree(PS(id));
PS(id) = NULL;
- send_cookie = 1;
+ PS(send_cookie) = 1;
if (PS(use_trans_sid))
PS(apply_trans_sid) = 1;
}
php_session_initialize(TSRMLS_C);
- if (!PS(use_cookies) && send_cookie) {
+ if (!PS(use_cookies) && PS(send_cookie)) {
if (PS(use_trans_sid))
PS(apply_trans_sid) = 1;
- send_cookie = 0;
- }
-
- if (send_cookie) {
- php_session_send_cookie(TSRMLS_C);
+ PS(send_cookie) = 0;
}
- /* if the SID constant exists, destroy it. */
- zend_hash_del(EG(zend_constants), "sid", sizeof("sid"));
+ php_session_reset_id(TSRMLS_C);
- if (define_sid) {
- smart_str var = {0};
-
- smart_str_appendl(&var, PS(session_name), lensess);
- smart_str_appendc(&var, '=');
- smart_str_appends(&var, PS(id));
- smart_str_0(&var);
- REGISTER_STRINGL_CONSTANT("SID", var.c, var.len, 0);
- } else {
- REGISTER_STRINGL_CONSTANT("SID", empty_string, 0, 0);
- }
-
PS(session_status) = php_session_active;
- if (PS(apply_trans_sid)) {
- php_url_scanner_add_var(PS(session_name), strlen(PS(session_name)), PS(id), strlen(PS(id)), 0 TSRMLS_CC);
- }
php_session_cache_limiter(TSRMLS_C);
}
/* }}} */
+/* {{{ proto string session_regenerate_id()
+ Update the current session id with a newly generated one. */
+PHP_FUNCTION(session_regenerate_id)
+{
+ if (PS(session_status) == php_session_active) {
+ if (PS(id)) efree(PS(id));
+
+ PS(id) = PS(mod)->s_create_sid(&PS(mod_data), NULL TSRMLS_CC);
+
+ php_session_reset_id(TSRMLS_C);
+
+ RETURN_TRUE;
+ }
+ RETURN_FALSE;
+}
+/* }}} */
+
/* {{{ proto string session_cache_limiter([string new_cache_limiter])
Return the current cache limiter. If new_cache_limited is given, the current cache_limiter is replaced with new_cache_limiter */
PHP_FUNCTION(session_cache_limiter)