Problems with the native session - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Problems with the native session (/showthread.php?tid=18840) Pages:
1
2
|
Problems with the native session - El Forum - 05-20-2009 [eluser]Zorancho[/eluser] Hi there, i have MY_Controller in the libraries folder and in its constructor i am starting a native session like this: class MY_Controller extends Controller { public function MY_Controller() { parent::__construct(); session_start(); } } It worked well on my server, but then i put the application on real server and it gets me this error: A PHP Error was encountered Severity: Warning Message: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at system/application/libraries/MY_Controller.php:1) Where i am suppose to start the session before any output starts? Thanks in advance Zoran Problems with the native session - El Forum - 05-20-2009 [eluser]Dam1an[/eluser] I would just put the session_start() in the index.php file That way you know its going to start before anything else Problems with the native session - El Forum - 05-20-2009 [eluser]Zorancho[/eluser] Message: Cannot modify header information - headers already sent by (output started at /home/bpetrusev/servis/system/application/libraries/MY_Controller.php:1) Filename: libraries/Session.php Line Number: 662 I removed the autoloading of the session library and i am using only native sessions, but i still get this error: A PHP Error was encountered Severity: Warning Message: Cannot modify header information - headers already sent by (output started at /home/bpetrusev/servis/system/application/libraries/MY_Controller.php:1) Filename: helpers/url_helper.php Line Number: 541 Problems with the native session - El Forum - 05-20-2009 [eluser]Dam1an[/eluser] Are you sure you don't have any whitespace in MY_Controller on line 1? Out of curiosity, why are you using native sessions over CI sessions? Problems with the native session - El Forum - 05-20-2009 [eluser]Zorancho[/eluser] I will do all of it with the CI Sessions.. but this is how my controller looks like <?php if(!defined('BASEPATH')) exit('No direct script access allowed'); class MY_Controller extends Controller { public function MY_Controller() { parent::__construct(); } public function destroy_sess() { $this->session->sess_destroy(); unset($_SESSION['userid']); unset($_SESSION['logged_in']); unset($_SESSION['role']); redirect('servis/'); } } Problems with the native session - El Forum - 05-20-2009 [eluser]Zorancho[/eluser] I even deleted MY_Controller, but still was getting this error again: Message: Cannot modify header information - headers already sent by (output started at /home/bpetrusev/servis/system/application/libraries/MY_Controller.php:1) And i am doing update and commit via svn, but i am still getting the error like MY_Controller still exists. I checked everywhere, but it still gives me the same error. Problems with the native session - El Forum - 05-20-2009 [eluser]TheFuzzy0ne[/eluser] Either your browser is caching the page, or you're editing the files in the wrong location. If MY_Controller.php has been deleted, then it can't possibly be causing an error, can it? Problems with the native session - El Forum - 05-20-2009 [eluser]Dam1an[/eluser] [quote author="TheFuzzy0ne" date="1242853291"]Either your browser is caching the page, or you're editing the files in the wrong location. If MY_Controller.php has been deleted, then it can't possibly be causing an error, can it?[/quote] Well, it would be causing an error saying it can't be found But thats not the error we're getting here :-S Problems with the native session - El Forum - 05-20-2009 [eluser]TheFuzzy0ne[/eluser] I meant in the sense that the error is occurring inside the supposedly deleted script. Don't be so facetious! Problems with the native session - El Forum - 05-20-2009 [eluser]rameners[/eluser] autoload session then forget about calling session_start(), it does the job for me... in this way you can use both the CI session and native sessions, IMO -> i think you autoload the session then calling again session_start() would cause the error. |