session_start(); and a little more

NorseMan

Member
Struggling a little, or a lot I would rather say with a scrip I set up over a 2-year period where I tried to get back to the old me as a programmer. I had a good number of skills before, but when you don't program anything at all during 12-15 years, it is quickly forgotten, and when you have to learn it again, it's not easy either when you have a cognitive head injury after a traffic accident in 1988 in addition to being 50 years old. Everything is a little slower than it used to be. So stupid questions that seem obvious to you may not be as obvious to me. This is also why I don't remember everything I did just a year or two ago as well.

I have a "session_start();". My page is assembled via "index.php" into a complete page of "header.php", "front.php" and "footer.php".

Is it not necessary that "session_start();" is included in other than "header.php"?

How do I retrieve a session stored in PHP, is it just like calling up/on a normal variable?

Can you tell me a bit about what the following lines do, and which lines are for "session_start", and what the others are for in that case? Is there something missing between () after session_start?

session_start();
$ROOT = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']) . '/';
$HOST = 'http://' . $_SERVER['HTTP_HOST'] . '/';
 
The session_start() gave you access to $_SESSION (save and read). session_start needs access to the http header, so it should be called before you print any html
 
Of course, I found out of it after so many days (no harm)😊👍👌
But it's good to have it well explained and formulated from you.
 
Back
Top