PHP Sessions broken after migration

Status
Not open for further replies.

cameron5

New Member
Messages
6
Reaction score
0
Points
1
Ever since the server migration my sessions have not been working. Which is highly inconvenient when I host my web design portfolio here. I get errors such as the following:
Code:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/cameron5/public_html/cameracircle/index.php:7) in/home/cameron5/public_html/cameracircle/includes/header.php on line 3
despite the only time sessions are started being in the header.php, there is no mention of session variables in index.php
Also when doing a
Code:
var_dump($_SESSION);
it returns NULL.

I need this sorted ASAP. My career actually depends on it.
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
session_start() may only be run before any headers are sent - this an extremely common PHP requirement.

Please ensure that you are not sending any data to the browser (whether it is HTML code, etc) before running session_start(). If in doubt, try running session_start() at the very start of your document and see if that fixes it :)

http://php.net/function.session-start

Thank you
 

cameron5

New Member
Messages
6
Reaction score
0
Points
1
What part of 'since migration' do you not understand? Let me rephrase my issue. My sessions where working perfectly on the server prior to server migration and continues to work perfectly locally but now after server migration they don't work on the server so do not take me for an idiot and fix the problem.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Read the error message:
output started at /home/cameron5/public_html/cameracircle/index.php:7

Go and look at the file /cameracircle/index.php

Line 7.

Something should be sending output. Even a blank line. Even one space.

You find it. You fix it. (I do not have access to your files).

If you are a "web developer" you should be able to do that.
 

cameron5

New Member
Messages
6
Reaction score
0
Points
1
Being rude to support volunteers when they are giving correct advice is, in general, not a good strategy
Explain to me how it was working a month ago and continues to work locally but on your server it does not despite no change to the file. It's not just that file. It's every single one. Regardless of where the session is started. So much for "support". Pathetic. You fix your server. If you are a "web host" you should be able to do that
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
It's not "the server" , it is apparently one corrupted file on your free account.

You can sit and complain, or you can actually try to fix it yourself.

Go to the cPanel File manager. Open public_html/cameracircle/index.php in the code editor. Copy the first ten lines. Post them here. Maybe I can help you find the problem.

The first five lines of public_html/cameracircle/includes/header.php might help too.
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
I have seen this type of error when PHP starts throwing errors or warnings (that send headers) after a change in the PHP version
check the PHP versions locally (yours) and on your free-hosting server - are they the same ?
 
Last edited:

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Explain to me how it was working a month ago and continues to work locally but on your server it does not despite no change to the file. It's not just that file. It's every single one. Regardless of where the session is started. So much for "support". Pathetic. You fix your server. If you are a "web host" you should be able to do that

It is impossible to create a session in PHP while the headers have already been sent; this is a simple fact of PHP. Our server runs standard PHP, and you are asking it to do the impossible. This is not our server's fault. How can you blame your code on our server? o_O

In any case, I'm not currently seeing any errors when navigating to the webpage correlating with the path you provided. Please provide a link to the page that is having problems if you still wish us to fix your code.
 

cameron5

New Member
Messages
6
Reaction score
0
Points
1
I have managed to find a way around it, hence why errors are now longer showing. It's 'fixed', but you still haven't answered my question: Explain to me how it was working a month ago and continues to work locally but on your server it does not despite no change to the file.
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
I have managed to find a way around it, hence why errors are now longer showing. It's 'fixed', but you still haven't answered my question: Explain to me how it was working a month ago and continues to work locally but on your server it does not despite no change to the file.
What version of PHP are you using locally? I do not believe you could have done this even before the migrations, as I described above.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
I have managed to find a way around it, hence why errors are now longer showing. It's 'fixed', but you still haven't answered my question: Explain to me how it was working a month ago and continues to work locally but on your server it does not despite no change to the file.

What was your "fix"? Be specific.

As I said, the migration moved files around. The files might have gotten corrupted. All it takes if for there to be one character before an opening <?php to cause your problem.
 
Status
Not open for further replies.
Top