title: How to construct a app.yaml file?
body: <p>I am trying out GAE for php and got lost in the app.yaml file construction. I can understand the part from the google tutorial which shows how to point all url request to a single file</p>
  
  <p><a href="https://developers.google.com/appengine/docs/php/gettingstarted/helloworld" rel="noreferrer">https://developers.google.com/appengine/docs/php/gettingstarted/helloworld</a></p>
  
  <p>But it does not help in my case. I am going to post what I have setup and the file structure is in the pic.<img src="https://i.stack.imgur.com/TRW3l.jpg" alt="enter image description here"></p>
  
  <p>App.yaml</p>
  
  <pre><code>application: xxx
  version: 1
  runtime: php
  api_version: 1
  threadsafe: true
  
  handlers:
  - url: /stylesheets
    static_dir: stylesheets
  
  - url: /images
    static_dir: images
  
  - url: /scripts
    static_dir: scripts
  
  - url: /favicon.ico
    static_files: favicon.ico
    upload: favicon.ico
  
  - url: /
    script: main.php
    login: required
    auth_fail_action: redirect
  
  - url: /main
    script: main.php
    login: required
    auth_fail_action: redirect
  </code></pre>
  
  <p>So my landing page for xxx.appspot.com or xxx.appsport.com/main would be main.php. And it works fine.</p>
  
  <p>main.php</p>
  
  <pre><code>&lt;?php
  session_start();
  date_default_timezone_set('America/Los_Angeles');
  require_once 'google/appengine/api/users/UserService.php';
  
  use google\appengine\api\users\User;
  use google\appengine\api\users\UserService;
  
  $user = UserService::getCurrentUser();
  $name= $user-&gt;getNickname();
  $name = explode(".",$name);
  $name[0]= ucfirst($name[0]);
  $name[1]= ucfirst($name[1]);
  $name = $name[0]." ".$name[1];
  $_SESSION['name']=$name;
  $_SESSION['email']= getenv('USER_EMAIL');
  
  header('Location: login.php');
  </code></pre>
  
  <p>So it loads starts a session and gets the user name and email do a few string formatting and then set as Session variable and then I check to match a condition and based on the condition redirect to another script which does some more validation and so on. To make is simple I am just redirecting it to login.php</p>
  
  <p>login.php</p>
  
  <pre><code>&lt;?php
  session_start();
  echo $_SESSION['name'];
  </code></pre>
  
  <p>So the out put displayed should be the session variable name but instead I get this</p>
  
  <p><img src="https://i.stack.imgur.com/GAKxW.jpg" alt="enter image description here"></p>
  
  <p>So what did I do wrong? I am going to use the login page to pull user data from a SQL db and based on the value redirect the user to different pages which will display different forms, tables, reports based on their settings. </p>
  
  <p>Eg. From login.php </p>
  
  <blockquote>
    <p>if userA belongs to Dept1 </p>
    
    <p>header('Location: /Dept1/main.php');</p>
    
    <p>Else </p>
    
    <p>header('Location: /Deptx/main.php');</p>
  </blockquote>
  
  <p>So I expect a lot of redirects and each of the redirects must be able to also carry over the session variables that are set. I as able to do this while running on normal PHP server. The GAE version requires some re learning. I would like to thank any one in advance just for taking time to read till hear. Thank you.</p>
  
  <p>Also it would be nice if some one could do a detail tutorial on how to use app.yaml and how it could be used with a demo example like in w3school.</p>