Click here to Skip to main content
15,937,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Working with core php, Using ob_start with session is gets complicated.

First Page



$_SESSION['mobile'] = "98057*****";



Next Page

echo $_SESSION['mobile'];

*It seems like $_SESSION['mobile'] does not have any value on next page. What is causing this ?

What I have tried:

Solution I already used is:
 - ob_clean() added after header().
 - ob_flush() added after header().
 - ob_end_clean() added after header.
 - ob_end_clean() at the end of the page.

But getting same problem. Any suggestions and help will be 

1 solution

Hello !

just make the ob_start before session_start.

PHP: session_start - Manual[^]

this case is fixed when you know that ob_start() is a new buffer creation, like does session_start()...
it's a conflict about buffer resources.
ob_start() maje the buffer area empty, so the session vars are deleted..
Share this answer
Satish Thakur 2022 21-Oct-22 5:11am    
putting ob_start() above not working, On the same page session giving value but not on another page. I'm still stuck :(
Do I need to use ob_clean() somewhere on page ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900