PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am unable to get a session to persist through an include() command. I have distilled the problem down to file a.php that includes file b.php. a.php starts a session, sets a session variable and includes b.php. b.php starts the session, changes the session variable and completes. a.php prints out the session variable. The change made by b.php to the session variable is not evident in the output of a.php.
File a.php:
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
maliskoleather wrote:you only need to include session_start() ONCE.
if its in a included file, it should throw an error. (its in the beginning of file b.php, and shouldnt be)
turn your error reporting on and set it to E_ALL.
But the reason it didn't throw an error is because it interpreted it as another website due to the http://, so the separate website had it's own session. Sort of like using cURL. Though, I was unaware you could include remotely.
maliskoleather wrote:you only need to include session_start() ONCE.
if its in a included file, it should throw an error. (its in the beginning of file b.php, and shouldnt be)
turn your error reporting on and set it to E_ALL.
But the reason it didn't throw an error is because it interpreted it as another website due to the http://, so the separate website had it's own session. Sort of like using cURL. Though, I was unaware you could include remotely.