HTTPS with php session in different page

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
php-forum Active User
php-forum Active User
Posts: 31
Joined: Fri Jan 08, 2021 8:10 pm

Tue Jan 12, 2021 10:44 pm

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

$_SESSION['user_ID'] = 8;

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

Thank you very much for your help
New php-forum User
New php-forum User
Posts: 1
Joined: Sat Feb 13, 2021 12:10 pm

Sat Feb 13, 2021 12:44 pm

Hi All, I have the same problem after upgrading the PHP server to, 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.
User avatar
php-forum GURU
php-forum GURU
Posts: 418
Joined: Sat Mar 23, 2013 8:24 am
Location: Livonia, MI

Sat Feb 13, 2021 2:47 pm

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"]);
I am also running version PHP 8 and haven had any problems.
Life is a fig newton of your imagination!
php-forum Fan User
php-forum Fan User
Posts: 137
Joined: Mon Jun 08, 2020 2:00 am

Sun Feb 14, 2021 6:38 am

Are both pages being loaded over https? This can cause problems depending on your PHP configuration.
Post Reply