Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2335 > unrolled thread
| Started by | Jivanmukta <jivanmukta@poczta.onet.pl> |
|---|---|
| First post | 2011-06-24 08:45 -0700 |
| Last post | 2011-06-24 16:06 -0400 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.php
library using $_SESSION Jivanmukta <jivanmukta@poczta.onet.pl> - 2011-06-24 08:45 -0700
Re: library using $_SESSION Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-24 16:06 -0400
| From | Jivanmukta <jivanmukta@poczta.onet.pl> |
|---|---|
| Date | 2011-06-24 08:45 -0700 |
| Subject | library using $_SESSION |
| Message-ID | <944b9083-66b5-4952-aecc-78cc54d959cb@q15g2000yqk.googlegroups.com> |
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.
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2011-06-24 16:06 -0400 |
| Message-ID | <iu2qnd$8sr$1@dont-email.me> |
| In reply to | #2335 |
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@attglobal.net ==================
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web