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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:53:35+00:00 2026-05-23T03:53:35+00:00

I recently realized that my modification to my website has caused sessions to stop

  • 0

I recently realized that my modification to my website has caused sessions to stop carrying between page reloads. After doing a little investigating, I noticed this line in the session_start() manual at PHP.net:

If a user uses ob_gzhandler or similar with ob_start(), the function order is important for proper output. For example, ob_gzhandler must be registered before starting the session.

The problem is, I call session_start() very early on in my page. I thought maybe adding the Gzip handler at the beginning, but that won’t work because I open and clean several output buffers throughout the process of script execution (usually 3 or 4 per page load). At the end of the page, I combine all the buffers by inserting them into each other and filling in data then open a final output buffer with Gzip handler and echo the final result to the page. Now the question: How can I continue to accomplish the Gzip compression through PHP and keep sessions working on the side? I tried just reopening the session again after opening the final output buffer but that had no effect. Opening an additional output buffer at the beginning just causes a content encoding error at the browser. Any ideas?

Here’s a very simplified snippet of code for visualization. Sorry, my code spans over several pages of lengthy coding, so I can’t paste everything.

session_start(); // The session is started early on for data

...

ob_start(); // Start an output buffer
echo "some content here"; // Some stuff is processed and sent
$data = ob_get_clean(); // That data is stored for later

...

ob_start(); // Another output buffer is started
echo "some other stuff"; // Different content for another piece of the page is sent
$moredata = ob_get_clean(); // That data is also stored for later use

...

ob_start(); // Another output buffer
echo $data.$moredata; // The data so far is more or less "combined" into the final template
$final = ob_get_clean(); // All of this is stored for final output
// Some other final touches are made to the final data here
ob_start("ob_gzhandler"); // Start the Gzip handler
echo $final; // Send the final output
  • 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-23T03:53:36+00:00Added an answer on May 23, 2026 at 3:53 am

    Grab the session id after calling session_start() with:

    $id = session_id();
    

    Then, at the end of your code, reconstitute the session using:

    session_id($id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently realized that the way my app icon and text look in the
I recently realized that one of my pages does not contain: $(#form1).validate(); call, however
It might look like a stupid question, but I recently realized that .NET implementation
I have application reads in data from text file. Recently I realized that I
I recently did some refactoring of my mvc application and realized that there are
I recently realized that I'm creating my n-tier applications using the Anemic Model, Which
I recently realized, when styling HTML5 input placeholder text, that this does not work:
Context I realized that in Twitter , the profile page is displayed in different
I recently started a Django project and I quickly realized that virtualenv will be
I recently realized that I can do this: void someFunc(const std::string &str) { //content

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.