HTTPS with php session in different page

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
nitiphone2021
New php-forum User
New php-forum User
Posts: 6
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

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
khumb
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 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.
User avatar
Strider64
php-forum GURU
php-forum GURU
Posts: 398
Joined: Sat Mar 23, 2013 8:24 am
Location: Livonia, MI
Contact:

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

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