Every time i deploy an app to google app engine i have the same problem: my session vars disapear when going from a page to another in the same web site. I dont have this issue when runing my app at my localhost, so i belive it is becouse of a wrong GAE configuration (im new at GAE).
i will show here one of my proyects:
app.yaml:
runtime: php73
# Defaults to "serve index.php" and "serve public/index.php". Can be used to
# serve a custom PHP front controller (e.g. "serve backend/index.php") or to
# run a long-running PHP script as a worker process (e.g. "php worker.php").
#
# Serve your app through a front controller at index.php or public/index.php.
runtime_config:
document_root: .
handlers:
# Serve images as static resources.
- url: /(.+\.(gif|png|jpg|css|js|map|PNG|svg))$
static_files: \1
upload: .+\.(gif|png|jpg|css|js|map|PNG|svg)$
- url: /.*
script: auto
index.php:
<?php
ini_set('allow_url_fopen',1);
switch (@parse_url($_SERVER['REQUEST_URI'])['path']) {
case '/':
require 'first.php';
break;
case '/first.php':
require 'first.php';
break;
case '/first':
require 'first.php';
break;
case '/second.php':
require 'second.php';
break;
case '/second':
require 'second.php';
break;
default:
require 'first.php';
break;
}
?>
first.php:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>fisrt</title>
</head>
<body>
<h1>first</h1>
<?php
session_start();
$_SESSION['id'] = 123;
$_SESSION['nombre'] = 'franc';
?>
<script>
window.location.href="second.php";
</script>
</body>
</html>
second.php:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Second</title>
</head>
<body>
<h1>Second</h1>
<?php
session_start();
echo $_SESSION['id'];
echo $_SESSION['nombre'];
?>
</body>
</html>
in my localhost, when i run this proyect, it works as expected: the front controller at index, redirects to first.php. first.php creates the sessions vars and it redirects to second.php. Finally second.php prints the values from the sesion vars.
However, when i deploy the same proyect to GAE, it shows the secon.php page without the session vars: image of second.php at GAE
PD: i just deploy the proyect at google app engine with no database instance.