173 Php_function (Setcookie) 174 { 175 char *name, *value = null, *path = NULL, *domain = NULL; 176 long expires = 0; 177 Zend_bool secure = 0, HttpOnly = 0; 178 int Name_len, Value_len = 0, Path_len = 0, Domain_len = 0; 179 if (Zend_parse_parameters (Zend_num_args () tsrmls_cc, "S|SLSSBB", &name, 181 &name_len, &value, &value_len, &expires, &path, 182 &path_len, &domain, &domain_len, &secure, &httponly) = = FAILURE) { 183 return; 184} 185 186 if (Php_setcookie (name, Name_len, value, Value_len, expires, path, Path_len, domain, Domain_len, secure, 1, httponly tsrmls_cc) = = SUCCESS) { 187 Retval_true; 188} else { 189 Retval_false; 190} 191}
Phpapi int Php_setcookie (char *name, int name_len, char *value, int value_len, time_t Expires, char *path, int path_len, char *domain, int domain_len, int secure, int url_encode, int HttpOnly tsrmls_dc) 77 { *cookie char, *encoded_value = NULL; len=sizeof int ("Set-cookie:"); *dt Char; Bayi Sapi_header_line ctr = {0}; The result of a. 83 if (name && strpbrk (name, "=,; trn1314 ")! = NULL) {/* man isspace for 13 and 14 */ Zend_error (e_warning, "Cookie names cannot contain any of the following ' =,; \t\r\n\013\014 ' "); FAILURE return; 87} 88 if (!url_encode && value && strpbrk (value, ",; trn1314 ") = NULL) {/* man Isspace for and 14 * * Zend_error (e_warning, "Cookie values cannot contain any of the following ',; \t\r\n\013\014 ' "); FAILURE return; 92} 94 Len + = Name_len; if (value && url_encode) { $ int encoded_value_len; + 98 en Coded_value = Php_url_encode (value, Value_len, &encoded_value_len); Len + encoded_value_len; + Else if (value) { 101 Encoded_value = estrdup (value); 102 Len + = Value_len; 103} 104 if (path) { . len + + Path_len; 106} 107 if (domain) { 108 len + domain_len; 109} 111 cookie = emalloc (len +); 113 if (value && Value_len = = 0) { * * * MSIE doesn ' t delete a cookie when you set it to a n ULL value $ * In order to force cookie to is deleted, even on MSIE, we 117 * Pick a expiry date in the past118 */ 119 dt = Php_format_date ("D, d-m-y h:i:s T", sizeof ("D, d-m-y h:i:s T")-1, 1, 0 TSRMLS_CC); snprintf (Cookie, Len +, "Set-cookie:%s=deleted; expires=%s ", name, DT); 121 efree (DT); 122} else { 123 snprintf (Cookie, Len +, "Set-cookie:%s=%s", name, value? Encoded_value: ""); 124 if (Expires > 0) { the const char *p; 126 Strlcat (Cookie, "; Expires= ", Len + 100); 127 dt = Php_format_date ("D, d-m-y h:i:s T", sizeof ("D, d-m-y h:i:s T")-1, Expires, 0 TSRMLS_CC); */* Check to make sure, the year does not exceed 4 digits in length */ 129 p = zend_memrchr (dt, '-', strlen (DT)); if (!p | | * (p + 5)! = ") { |