0

I have 2 independent application which is built on Zend framework with php-fpm and running on Nginx on the same server. When I' m calling API from one application to another application. Session are creating for each request under following folder "/var/lib/php/session". The above function is called only one time when the user is logged in.

if (session_status() == PHP_SESSION_NONE || session_status() !== PHP_SESSION_ACTIVE) 
{
    session_start();
} 

The NGINX configuration is below:

First Application:

  server 
  { 

      listen       80 default;
      listen       443 ssl;
      server_name  $hostname;
      client_max_body_size 16384M;

      location / 
      {
          add_header 'Access-Control-Allow-Origin' "*";
          add_header 'Access-Control-Allow-Credentials' 'true';
          add_header 'Access-Control-Allow-Headers' 'Content-Type,accept,x-wsse,origin';
          add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';

          root /../first_application/public;
          index  index.php index.phtml index.html index.htm;
          try_files $uri $uri/ /index.php$is_args$args;
       }

       location ~ \.php$ 
       {
          root /../first_application/public;
          try_files $uri =404;
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_intercept_errors on;
          fastcgi_read_timeout 300;
          include fastcgi_params;
      }

      location ~ /\.ht 
      {
          deny  all;
      }
}

Second Application:

server 
{ 
  listen       8118 default;
  listen       8119 ssl;
  server_name  $hostname:8119;
  client_max_body_size 16384M;

  location / 
  {
      add_header 'Access-Control-Allow-Origin' "*";
      add_header 'Access-Control-Allow-Credentials' 'true';
      add_header 'Access-Control-Allow-Headers' 'Content-Type,accept,x-wsse,origin';
      add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';

      root /../second_application/public;
      index  index.php index.phtml index.html index.htm;
      try_files $uri $uri/ /index.php$is_args$args;
   }

  location ~ \.php$ 
  {        
      root /../second_application/public;
      try_files $uri =404;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_intercept_errors on;
      fastcgi_read_timeout 300;
      include fastcgi_params;
     }
  location ~ /\.ht
  {
      deny  all;
  }
}
aminography
  • 21,986
  • 13
  • 70
  • 74
Lokesh R
  • 1
  • 1
  • Hey @Lokesh R Welcome to SO. Can you please specify a little more what exactly your question is? – Ramsha Omer Oct 31 '19 at 07:01
  • @RamshaSaeed Hi thank you for your response. Actually i have 2 php application which is build using zend framework. Think APP-1 & APP-2 ,both are hosted in same server. In APP-1 there is a ajax call which is calling APP-2 API for every 10 seconds to get some data from APP-2. That time for every API hit, new session is getting created – Lokesh R Nov 05 '19 at 06:58

0 Answers0