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

  • SEARCH
  • Home
  • 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 8095195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:02:32+00:00 2026-06-05T21:02:32+00:00

I try to output my .php files from the command line and I want

  • 0

I try to output my .php files from the command line and I want to be able to simulate $_SESSION values for this output.

I tried php test.php --define $_SESSION["id"]=1 but it does not set the global variable $_SESSION.

I am obviously not using the command line correctly but I cannot find how I should do.

Any idea to make it work?

Thanks a lot

EDIT: for my example test.php is the following:

<? echo $_SESSION['id'];?>
  • 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-05T21:02:35+00:00Added an answer on June 5, 2026 at 9:02 pm
    $ cat setsession.php 
    <?php
    //fixed session:
    session_id("fixed");
    session_start();
    ?>
    $ cat checksession.php 
    <?php
    if(!isset($_SESSION['counter'])) $_SESSION['counter'] = 0;
    
    $_SESSION['counter']++;
    
    var_dump($_SESSION);
    $ php -d auto_prepend_file=setsession.php checksession.php 
    array(1) {
      ["counter"]=>
      int(1)
    }
    $ php -d auto_prepend_file=setsession.php checksession.php 
    array(1) {
      ["counter"]=>
      int(2)
    }
    $ php -d auto_prepend_file=setsession.php checksession.php 
    array(1) {
      ["counter"]=>
      int(3)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the command I've been using for finding matches (queryString) in php files,
i try to run php processes in background and start this from an php
I need to read the output from ffmpeg in order to even try the
I am using this code to try to get json data from many json
When ever I try to execute a command to the shell via php's exec/passthru/system
I have created this php script, to create an xml-file from my database: <?php
I am trying to ultimately extract some files from a tar archive within PHP,
I have a variabla var. If I try to output its value in HAML
hello guys i am try to print the output of two element data simultaneously
Is it possbile to clear erlang shell current output for next time's try and

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.