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 8425693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:20:33+00:00 2026-06-10T04:20:33+00:00

Question is in the title. I can access $_COOKIE[‘blah’] in my php file in

  • 0

Question is in the title.

I can access $_COOKIE['blah'] in my php file in the webroot, but I have includes outside of webroot for security purposes that can’t access it.

Example

/home/wwwroot/index.php CAN read $_COOKIE[‘blah’]

Where it’s full path would be http://www.mydomain.com/index.php.

/home/scrape/process.php CAN NOT read $_COOKIE[‘blah’]

But it is outside the webroot, and the scrape folder can’t be access outside of the server.

Index.php can echo the value stored in the cookie and will also write a timestamp with the value to a log file. This works.

Without posting ALL the code and trying to keep this simple and it’s just something simple like so:

<?PHP
include '../scrape/process.php'; // THIS FILE IS OUTSIDE THE WEBROOT
$cook=$_COOKIE['blah'];

echo "Cookie value is : " . $_COOKIE['blah'] ;
error_log('['.date("F j, Y, g:i a e O").']'.$cook."<br /> \n", 3,  $phperrorPath);
?>

<?PHP
echo 'Outer cookie is : ';
echo outer_cookie();
?>

Process.php function is called from index.php where it will then return the value of the cookie, and also write it’s own log file with timestamp and cookie value. This does not work. The log file has only timestamp with no value, and it doesn’t return anything to index.php.

function outer_cookie() 
{ 
    $cook=$_COOKIE['blah'];
    error_log('['.date("F j, Y, g:i a e O").']'.$cook."<br /> \n", 3,  $phperrorPath);
    return $cook; 
} 

How can I get process.php to read the cookie data? I obviously can’t set the cookie path to something outside of the webroot, and even if I could, then it wouldn’t be accessible to everything in the webroot…

Do I have to use $_SESSION along side the cookie? I would hate to have to duplicate the work…

  • 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-10T04:20:35+00:00Added an answer on June 10, 2026 at 4:20 am

    Do make this work both file should be in your domain or subdomains of one domain.

    You cannot access the cookie set in index.php in a file that does not have web access and it’s not parsed by the browser.

    Check php.net:

    Cookies are a mechanism for storing data in the remote browser and thus tracking or identifying return users. Cookies are part of the HTTP header, so setcookie() must be called before any output is sent to the browser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a bad title for the question, but I can't think of a
My question is not clear at title [i can not write it exactly] e.g
Well, question is in title. Is it possible at all? I can use css
the title already tells the question: you can successfully call the Print-Method on a
The title pretty much asks the whole question - How can I clear ONLY
Apologies for the poor question title. I have two tables, jobs and Persons-Jobs. Jobs
I really don't know how to title this question, but I need some help
Sorry for the long title, but it seems most descriptive for my question. Basically,
I had some problem formulating the question in the title, but i hope you
how can i access a variable that was intialsed in a function, but the

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.