I created a social website where users can register and see each other's posts. It works fine on my local server, but when I tried uploading to 000webhost.com the "session already started" error is shown. Is there a way to solve this problem ? Thanks!
            Asked
            
        
        
            Active
            
        
            Viewed 287 times
        
    1
            
            
        - 
                    2Don't start the session twice. It gives you the file name where it happens and the line number. Magic. – Xorifelse Jul 17 '18 at 16:06
- 
                    1I assume this is the "free" webhosting 000webhost offers. Remember, that "free" service uses PHP 5.2, which is WAY beyond [End of Life](http://php.net/eol.php) – Machavity Jul 17 '18 at 16:11
- 
                    1I tried to provide my code but error occured "your code is not formatted" – Best Bibek Jul 17 '18 at 16:15
1 Answers
1
            
            
        You can use this code before starting session:
For PHP >= 5.4.0
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
For PHP < 5.4.0
if(session_id() == '') {
    session_start();
}
 
    
    
        Perfecto Web
        
- 182
- 6
 
    