Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8721993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:18:52+00:00 2026-06-13T07:18:52+00:00

i have a first PHP file: /home/www/subdomain1.domain.tld/file.php <?php session_start(); $_SESSION[‘foo’]=’bar’; include /home/www/subdomain2.domain.tld/foo2.php; ?> and

  • 0

i have a first PHP file:
/home/www/subdomain1.domain.tld/file.php

<?php
    session_start();
    $_SESSION['foo']='bar';   
    include "/home/www/subdomain2.domain.tld/foo2.php";
 ?>

and /home/www/subdomain2.domain.tld/foo2.php:

<?php 
    session_start();
    echo $_SESSION['foo'];
?>

The “include” in the first file generates a “500 Internal Server Error”, i think it’s because session variables are not passed to included files, how can i fix that?

Thank you
Alex

EDIT:
I must use session variables in order to use these variables on every php file on subdomain2.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:18:53+00:00Added an answer on June 13, 2026 at 7:18 am

    You don’t need to use sessions when including a file. It is all the same request with the same namespace.

    file.php:

    $foo = 'bar';
    
    include 'foo2.php';
    

    foo2.php

    echo $foo; // returns 'bar'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have three files index.php file.php and fns.php First example (it works): index.php
First I have a PHP file that gets data and file from a HTML
Some setup background first: I have a cronjob which runs a PHP file called
I have a php file somejson.php that echos a json encoded array {jsonone:first json,jsontwo:second
I have 3 files 1) show_createtable.html 2) do_showfielddef.php 3) do_showtble.php 1) First file is
I have a nested php array. I have the first select populated already. I
I will be writing my first daemon in php and I have a couple
I have a little problem with some preg_replace functions in PHP. First I have
I have started using PDO in php for the first time. Here is my
Currently developing a PHP framework and have ran into my first problem. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.