Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
b93ce19a
Commit
b93ce19a
authored
17 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#56357
by John Albin, alienbrain, moshe, etc: fixed more cookie domain problems.
parent
24870347
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
includes/bootstrap.inc
+28
-2
28 additions, 2 deletions
includes/bootstrap.inc
sites/default/settings.php
+8
-20
8 additions, 20 deletions
sites/default/settings.php
with
36 additions
and
22 deletions
includes/bootstrap.inc
+
28
−
2
View file @
b93ce19a
...
...
@@ -256,13 +256,14 @@ function drupal_unset_globals() {
}
/**
* Loads the configuration and sets the base URL correctly.
* Loads the configuration and sets the base URL, cookie domain, and
* session name correctly.
*/
function
conf_init
()
{
global
$base_url
,
$base_path
,
$base_root
;
// Export the following settings.php variables to the global namespace
global
$db_url
,
$db_prefix
,
$conf
,
$installed_profile
;
global
$db_url
,
$db_prefix
,
$cookie_domain
,
$conf
,
$installed_profile
;
$conf
=
array
();
include_once
'./'
.
conf_path
()
.
'/settings.php'
;
...
...
@@ -290,6 +291,31 @@ function conf_init() {
$base_path
=
'/'
;
}
}
if
(
$cookie_domain
)
{
// If the user specifies the cookie domain, also use it for session name.
$session_name
=
$cookie_domain
;
}
else
{
// Otherwise use $base_url for session name.
$session_name
=
$base_url
;
// We try to set the cookie domain to the hostname.
if
(
!
empty
(
$_SERVER
[
'HTTP_HOST'
]))
{
$cookie_domain
=
$_SERVER
[
'HTTP_HOST'
];
}
}
// Strip leading periods, www., and port numbers from cookie domain.
$cookie_domain
=
ltrim
(
$cookie_domain
,
'.'
);
if
(
strpos
(
$cookie_domain
,
'www.'
)
===
0
)
{
$cookie_domain
=
substr
(
$cookie_domain
,
4
);
}
$cookie_domain
=
'.'
.
array_shift
(
explode
(
':'
,
$cookie_domain
));
// Per RFC 2109, cookie domains must contain at least one dot other than the
// first. For hosts such as 'localhost' or IP Addresses we don't set a cookie domain.
if
(
count
(
explode
(
'.'
,
$cookie_domain
))
>
2
&&
!
is_numeric
(
str_replace
(
'.'
,
''
,
$cookie_domain
)))
{
ini_set
(
'session.cookie_domain'
,
$cookie_domain
);
}
session_name
(
'SESS'
.
md5
(
$session_name
));
}
/**
...
...
This diff is collapsed.
Click to expand it.
sites/default/settings.php
+
8
−
20
View file @
b93ce19a
...
...
@@ -137,27 +137,15 @@
ini_set
(
'url_rewriter.tags'
,
''
);
/**
* We try to set the correct cookie domain.
*/
if
(
isset
(
$_SERVER
[
'HTTP_HOST'
]))
{
$domain
=
'.'
.
preg_replace
(
'`^www\.`'
,
''
,
$_SERVER
[
'HTTP_HOST'
]);
// Per RFC 2109, cookie domains must contain at least one dot other than the
// first. For hosts such as 'localhost', we don't set a cookie domain.
if
(
count
(
explode
(
'.'
,
$domain
))
>
2
)
{
ini_set
(
'session.cookie_domain'
,
$domain
);
}
}
* Drupal automatically generates a unique session cookie name for each site
* based on on its full domain name. If you have multiple domains pointing at
* the same Drupal site, you can either redirect them all to a single
* domain (see comment in .htaccess), or uncomment the line below and specify
* their shared base domain. Doing so assures that users remain logged in as they
* cross between your various domains.
*/
/**
* On some sites, multiple domains or subdomains may point to the same site.
* For instance, example.com may redirect to foo.example.com. In that case,
* the browser may confuse the cookies between the two domains, resulting in
* an inability to log in. In that case, uncomment the line below and set
* it to the more generic domain name. For instance, .example.com is more
* generic than .foo.example.com. Remember the leading period on the domain
* name, even if you wouldn't type it in your browser.
*/
#ini_set('session.cookie_domain', '.example.com');
#$cookie_domain = 'example.com';
/**
* Variable overrides:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment