Home »
Imported messages »
comp.lang.php »
library using $_SESSION
library using $_SESSION [message #174659] |
Fri, 24 June 2011 15:45 |
Jivanmukta
Messages: 20 Registered: January 2011
Karma: 0
|
Junior Member |
|
|
I created library of PHP5 functions that use $_SESSION. Which solution
is better:
1. Add session_start() at the top of library file
2. Add a comment that library users shoud call session_start().
Please help. I have little experience in PHP5.
|
|
|
Re: library using $_SESSION [message #174660 is a reply to message #174659] |
Fri, 24 June 2011 20:06 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 6/24/2011 11:45 AM, Jivanmukta wrote:
> I created library of PHP5 functions that use $_SESSION. Which solution
> is better:
> 1. Add session_start() at the top of library file
> 2. Add a comment that library users shoud call session_start().
> Please help. I have little experience in PHP5.
I would say that you should require the user to issue the
session_start() call. A couple of reasons:
1. Your library may not be included at the start of the page, and
session_start() will fail if ANY output is produced before the call.
2. The user may issue his/her own session_start() call, in which case
the second call (whichever it may be) will fail.
Libraries shouldn't do anything other than what they are told to do with
no side effects; in this case your library hasn't been told to issue the
session_start() call.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Goto Forum:
Current Time: Fri Nov 22 21:44:52 GMT 2024
Total time taken to generate the page: 0.03125 seconds