Reputation: 239
I have 3 environments for PHP.
The issue is that when I calling session in sub directory after session_start()
that gives error that headers are already sent & kills existing session. And If I do not start session then it gives error for Undefined variable _SESSION.
Session is working only in ROOT directory. but not work in Subdirectory.
This only occurs on Live Environment. This same code is working on Local & Staging but not on Live.
I don't know but this may be PHP configuration issue. Please guide me.
Upvotes: 3
Views: 1243
Reputation: 2525
Add session_start() at the beginning of your main page. Please ensure that if you are including some other file, session_start() is not defined there else error will display.
Upvotes: 1
Reputation: 1905
The first line of php should be session_start(). If you include/add php page which contain session_start() into another page, it will show error "header already sent".
Add session_start() at the beginning of your page main page.
Upvotes: 0