Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: A session had already been started - ignoring session_start() comes only in windows [duplicate]

Tags:

php

Possible Duplicate:
PHP sessions that have already been started

I have run a my PHP project on windows and also Mac with same code . But I got this error when I run my project in windows not in Mac.

error message is .

A session had already been started - ignoring session_start()

which is come only on Windows system. But In Mac I didnt get any error message. Please any one give me a solution .....

like image 482
Muthuraj Muthulingam Avatar asked Dec 07 '12 08:12

Muthuraj Muthulingam


2 Answers

You said that you starts session with a check:

if(!isset($_SESSION)){
    session_start();
}

The fact is the $_SESSION always exists and if you aren't put something in it then it will be always empty, so the statment will return always true.

like image 196
Peter Kiss Avatar answered Sep 22 '22 05:09

Peter Kiss


I didnt know why windows shows the error and Mac dont. But You can try to replace all the session_start() by

if(!isset($_SESSION)) 
    { 
        session_start(); 
    } 

This will may help you..

like image 25
Sridhar Avatar answered Sep 21 '22 05:09

Sridhar