@@ -1636,50 +1636,47 @@ PHPAPI void php_session_start(void) /* {{{ */
1636
1636
PS (define_sid ) = 0 ;
1637
1637
}
1638
1638
}
1639
-
1640
- if (PS (define_sid ) && !PS (id ) && (data = zend_hash_str_find (& EG (symbol_table ), "_GET" , sizeof ("_GET" ) - 1 ))) {
1641
- ZVAL_DEREF (data );
1642
- if (Z_TYPE_P (data ) == IS_ARRAY && (ppid = zend_hash_str_find (Z_ARRVAL_P (data ), PS (session_name ), lensess ))) {
1643
- ppid2sid (ppid );
1639
+ /* Initilize session ID from non cookie values */
1640
+ if (!PS (use_only_cookies )) {
1641
+ if (!PS (id ) && (data = zend_hash_str_find (& EG (symbol_table ), "_GET" , sizeof ("_GET" ) - 1 ))) {
1642
+ ZVAL_DEREF (data );
1643
+ if (Z_TYPE_P (data ) == IS_ARRAY && (ppid = zend_hash_str_find (Z_ARRVAL_P (data ), PS (session_name ), lensess ))) {
1644
+ ppid2sid (ppid );
1645
+ }
1644
1646
}
1645
- }
1646
-
1647
- if (PS (define_sid ) && !PS (id ) && (data = zend_hash_str_find (& EG (symbol_table ), "_POST" , sizeof ("_POST" ) - 1 ))) {
1648
- ZVAL_DEREF (data );
1649
- if (Z_TYPE_P (data ) == IS_ARRAY && (ppid = zend_hash_str_find (Z_ARRVAL_P (data ), PS (session_name ), lensess ))) {
1650
- ppid2sid (ppid );
1647
+ if (!PS (id ) && (data = zend_hash_str_find (& EG (symbol_table ), "_POST" , sizeof ("_POST" ) - 1 ))) {
1648
+ ZVAL_DEREF (data );
1649
+ if (Z_TYPE_P (data ) == IS_ARRAY && (ppid = zend_hash_str_find (Z_ARRVAL_P (data ), PS (session_name ), lensess ))) {
1650
+ ppid2sid (ppid );
1651
+ }
1651
1652
}
1652
- }
1653
-
1654
- /* Check the REQUEST_URI symbol for a string of the form
1655
- * '<session-name>=<session-id>' to allow URLs of the form
1656
- * http://yoursite/<session-name>=<session-id>/script.php */
1657
- if (PS (define_sid ) && !PS (id ) &&
1658
- zend_is_auto_global_str ("_SERVER" , sizeof ("_SERVER" ) - 1 ) == SUCCESS &&
1659
- (data = zend_hash_str_find (Z_ARRVAL (PG (http_globals )[TRACK_VARS_SERVER ]), "REQUEST_URI" , sizeof ("REQUEST_URI" ) - 1 )) &&
1660
- Z_TYPE_P (data ) == IS_STRING &&
1661
- (p = strstr (Z_STRVAL_P (data ), PS (session_name ))) &&
1662
- p [lensess ] == '='
1663
- ) {
1664
- char * q ;
1665
- p += lensess + 1 ;
1666
- if ((q = strpbrk (p , "/?\\" ))) {
1667
- PS (id ) = zend_string_init (p , q - p , 0 );
1653
+ /* Check the REQUEST_URI symbol for a string of the form
1654
+ * '<session-name>=<session-id>' to allow URLs of the form
1655
+ * http://yoursite/<session-name>=<session-id>/script.php */
1656
+ if (!PS (id ) && zend_is_auto_global_str ("_SERVER" , sizeof ("_SERVER" ) - 1 ) == SUCCESS &&
1657
+ (data = zend_hash_str_find (Z_ARRVAL (PG (http_globals )[TRACK_VARS_SERVER ]), "REQUEST_URI" , sizeof ("REQUEST_URI" ) - 1 )) &&
1658
+ Z_TYPE_P (data ) == IS_STRING &&
1659
+ (p = strstr (Z_STRVAL_P (data ), PS (session_name ))) &&
1660
+ p [lensess ] == '='
1661
+ ) {
1662
+ char * q ;
1663
+ p += lensess + 1 ;
1664
+ if ((q = strpbrk (p , "/?\\" ))) {
1665
+ PS (id ) = zend_string_init (p , q - p , 0 );
1666
+ }
1667
+ }
1668
+ /* Check whether the current request was referred to by
1669
+ * an external site which invalidates the previously found id. */
1670
+ if (PS (id ) && PS (extern_referer_chk )[0 ] != '\0' &&
1671
+ !Z_ISUNDEF (PG (http_globals )[TRACK_VARS_SERVER ]) &&
1672
+ (data = zend_hash_str_find (Z_ARRVAL (PG (http_globals )[TRACK_VARS_SERVER ]), "HTTP_REFERER" , sizeof ("HTTP_REFERER" ) - 1 )) &&
1673
+ Z_TYPE_P (data ) == IS_STRING &&
1674
+ Z_STRLEN_P (data ) != 0 &&
1675
+ strstr (Z_STRVAL_P (data ), PS (extern_referer_chk )) == NULL
1676
+ ) {
1677
+ zend_string_release (PS (id ));
1678
+ PS (id ) = NULL ;
1668
1679
}
1669
- }
1670
-
1671
- /* Check whether the current request was referred to by
1672
- * an external site which invalidates the previously found id. */
1673
- if (PS (define_sid ) && PS (id ) &&
1674
- PS (extern_referer_chk )[0 ] != '\0' &&
1675
- !Z_ISUNDEF (PG (http_globals )[TRACK_VARS_SERVER ]) &&
1676
- (data = zend_hash_str_find (Z_ARRVAL (PG (http_globals )[TRACK_VARS_SERVER ]), "HTTP_REFERER" , sizeof ("HTTP_REFERER" ) - 1 )) &&
1677
- Z_TYPE_P (data ) == IS_STRING &&
1678
- Z_STRLEN_P (data ) != 0 &&
1679
- strstr (Z_STRVAL_P (data ), PS (extern_referer_chk )) == NULL
1680
- ) {
1681
- zend_string_release (PS (id ));
1682
- PS (id ) = NULL ;
1683
1680
}
1684
1681
}
1685
1682
0 commit comments