Welcome Guest, Not a member yet? Register   Sign In
using sessions
#1

[eluser]/larry[/eluser]
I tried to use the built in session class, but when I run the app on linux it would give an error message something like:

headers already sent by (output started at /apps/genwidgets/eng/php/system/application/controllers/widget.php:2)

I didn't have any such problem on my windows PHP.

On linux, I also tried using sessions the regular way and called session_start() myself, which I tried to do in the constructor or even before the controller, but I seemed to have the same problem. For awhile using the $_SESSION variable seemed to be working without calling session_start() at all, and then it stopped working so I am somewhat confused.

Can I use sessions the regular way, or how can I figure out what could be happening
?


here is the session output from phpInfo():


session.auto_start Off Off
session.bug_compat_42 On On
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly Off Off
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 100 100
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 4 4
session.hash_function 0 0
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path no value no value
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid 0 0
#2

[eluser]gtech[/eluser]
what is line 2 of widget.php?

if you echo any content, load a view or have white spaces outside the <?php ..... ?> tags in the controller you will see the error you are seeing. it is also possible that an external file you include/load might also have spaces outside the php tags or echo content.
#3

[eluser]/larry[/eluser]
that may have been it,

I had started <?php on line 2 instead of line 1 ...
#4

[eluser]gtech[/eluser]
yep that would do it Smile. if there is any content outside the php tags, the content will end up being sent to the browser, which means a document head will be sent.. as setting the session needs to set information in the head you will get the error you see.
#5

[eluser]Scriptor[/eluser]
A good practice is to not include your closing PHP tags in files like controllers and models, where nothing would come after those tags. It makes sure that any whitespace at the end of the file is not counted.




Theme © iAndrew 2016 - Forum software by © MyBB