Edit 4: Why this question is not a duplicate to the linked question
While the underlying problem turned out to be the same as in the linked question, I did not receive the error message Headers not send, so the answer, which I read, was not useful to me at this time. Thus, this question, while maybe overly long, has merit on it's own.
Sorry to bother you, but after two days of research, I broke down. I'll try to give the maximum amount of information.
What I'm doing:
I am currently writing a login system, just for fun. Registering, entering data into the database, loging in works perfectly fine. I host with 1and1, my database is there as well.
Now to keep going, I wanted to start with sessions. Initially, all seemed well and simple.
//returns true when put into an if()
$_SESSION['id'] = //user ID read from databse
echo $_SESSION['id']; //prints out the ID just fine.
When I go to another page, I instantly call session_start(); again.
In fact, ALL my pages start with
$con = startup();
//statup(); is in functions.php, connects to a databse,
//calls session_start(); succesfully, then returns the connection.
The problem should not be in the function, since it works fine, also I tried the connection/session starting thing to be in every file, rather than a shared function - didn't change anything.
But none of the session variables retain values.
Cookies are not send
Chrome tells me no cookies are received, also none blocked.
I don't know what to make of this.
My host doesn't allow sessions
Was another idea of mine. However, I can see my php_info(); and it tells me:
Session Support enabled
session.cookie_domain no value
Those are just the lines which seem somewhat relevant to me.
So, what I read from that is that sessions should work just fine, with cookies and stuff. But I don't really understand this level either.
So, thats where I'm stuck. All the components of my code work fine, I'm quite sure the syntax is right, as far as I understand it the server supports sessions.
Oh, I've also tried changing the session path from /tmp to a directory right on my webspace - It didn't seem to do anything, no data was stored on my "part" of the server.
I sincerely hope I didn't annoy you with an overly long, simple question because I made a small misstake somewhere. I genuinely tried to work this out by googling other peoples problems for two days now.
I thank you all for your time, patience and help.
Using the new information about error_reporting(E_ALL); I now recieved the generic error message
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /homepages/23/d315777983/htdocs/mtm/index.php:14) in /homepages/23/d315777983/htdocs/mtm/functions.php on line 9
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /homepages/23/d315777983/htdocs/mtm/index.php:14) in /homepages/23/d315777983/htdocs/mtm/functions.php on line 9
I guess I can start working with older suggested solutions now.
As suggested, I added print_r($_SESSION); after the include.
It just prints "Array()" (without quotation marks)
I also moved session_start back into each individual file, called BEFORE functions.php is included.
It says cookies are send at line 14 - which in my code is literally just
Well, I'll read more answers on this for now. Thanks a lot!
Well, that was some wasted time. Removed whitespace at the end of functions.php, called startup(); before any html output and now it works perfectly.
Thanks a lot to all of you!