I think I read and tried all relevant topics about "sessions, cross-domain and ssl" here on stackoverflow . Unfortunately nothing works.
My case:
loginForm.html (non-SSL) -> authUser.php (SSL) -> showAccount.php (non-SSL)
The problem is, that these files are placed on different subdomains and served by SSL or non-SSL.
loginForm.html -> http://dev.domain.com
authUser.php -> https://ssl.domain.com
showAccount.php -> http://dev.domain.com
If the user credentials are correct, the authUser.php
should create the session which is used by showAccount.php
.
As already mentioned, I tried all posted solutions.
For reference let's take a look at this: Session lost when switching from HTTP to HTTPS in PHP .
I also tried to extend this snippet with session_set_cookie_params
as mentioned in PHP Sessions across sub domains but this neither works.
I also tried ini_set('session.cookie_domain', '.domain.com');
Edit: As in the answers requested, here is the used code (which was originally posted by Jacob here: Session lost when switching from HTTP to HTTPS in PHP)
https://ssl.domain.com/user/authUser.php
<?php
// auth with database was successful, so create the session
session_set_cookie_params(0, '/', '.domain.com');
session_start();
$currentSessionID = session_id();
$_SESSION['testvariable'] = 'It worked';
$InsecureServerDomain = 'dev.domain.com';
$pagePath = '/showAccount.php';
echo '<a href="http://' . $InsecureServerDomain . $pagePath . '?session=' . $currentSessionID . '">Transfer Cookie from secure to insecure </a>';
?>
http://dev.domain.com/showAccount.php
<?php
$currentSessionID = filter_input(GET, "session");
session_set_cookie_params(0, '/', '.domain.com');
session_id($currentSessionID);
session_start();
if (!empty($_SESSION['testvariable'])) {
echo $_SESSION['testvariable'];
} else {
echo 'It did not work.';
}
?>
The $_SESSION
is always empty.
Are there any hints?