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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:21:25+00:00 2026-05-12T05:21:25+00:00

I would like to separate my source folders into two: The folders that contain

  • 0

I would like to separate my source folders into two: The folders that contain the code that you type into the address bar and those that make up parts of the page (tiles) and other code (classes, etc). So at the start of every php file I added:

<?php
// index.php
include("config.php");
include("session.php");
?>

Config contains just this so far, but allows me to expand if I need other directories (logs, etc.)

<?php
// config.php
$_PATHS["base"]      = dirname(dirname(__FILE__)) . "\\";
$_PATHS["includes"]  = $_PATHS["base"] . "includes\\";
ini_set("include_path", "$_PATHS[includes]");
?>

And session has amongst other things, in the constructor, a call to session_start. It also requires other classes which are included elsewhere – which necessitates the config being listed before the session inclusion. However I get the error

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started ...

If I switch the includes around that particular error goes away but I need to start manually munging the links to the header files. Is there anyway of setting the directories first and still being able to use sessions or must session_start be the very first thing the a file includes?

  • 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-05-12T05:21:25+00:00Added an answer on May 12, 2026 at 5:21 am

    I don’t know if you have already tried this, but as a means of testing remove the config.php include and paste the config code in there instead.

    So this:

    <?php
    // index.php
    include("config.php");
    include("session.php");
    ?>
    

    becomes this:

    <?php
    // config
    $_PATHS["base"]      = dirname(dirname(__FILE__)) . "\\";
    $_PATHS["includes"]  = $_PATHS["base"] . "includes\\";
    ini_set("include_path", "$_PATHS[includes]");
    //index
    include("session.php");
    ?>
    

    If it works then you have a problem with your config.php file* [see below], if it doesn’t, does the error still point to the ini_set line? [assuming from your above comment that’s where the current error points]

    *I remember reading once [a while ago I admit] that a file being UTF-8 might screw up sessions. Trying to find a link

    Ok I found someone who submitted a bug report concerning UTF-8 and session_start. Apparantly it isn’t a bug – I didn’t look into why – but either way it isn’t quite the same issue. A type of UTF-8 encoding does cause session errors, just not the cookie error you are getting. See here if you are interested – UTF-8 Error

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

Sidebar

Related Questions

No related questions found

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.