Page 1 of 1

HTTPS with php session in different page

Posted: Tue Jan 12, 2021 10:44 pm
by nitiphone2021
Hi friends.
I have a problem with https about $_SESSION in php
last time my website is working correctly with http but after change to https I can send value of session to another page

login.php
session_start();
$_SESSION['user_ID'] = 8;

Action.php
session_start();
echo "User ID = " . $_SESSION['user_ID'] ; //// It's not show any thing

Thank you very much for your help

Re: HTTPS with php session in different page

Posted: Sat Feb 13, 2021 12:44 pm
by khumb
Hi All, I have the same problem after upgrading the PHP server to 7.4.1.4, once i redirect to another page with "header function"....the $_SESSION is not set anymore. Even though all my affected pages start with "session_start(); at the top. Please help.

Re: HTTPS with php session in different page

Posted: Sat Feb 13, 2021 2:47 pm
by Strider64
I have session_start() in my config.php file and I also have this is it as well ->

Code: Select all

if($_SERVER["HTTPS"] != "on")
{
    header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
    exit();
}
I am also running version PHP 8 and haven had any problems.

Re: HTTPS with php session in different page

Posted: Sun Feb 14, 2021 6:38 am
by simonbrahan
Are both pages being loaded over https? This can cause problems depending on your PHP configuration.