NYCPHP Meetup

NYPHP.org

[nycphp-talk] accessing $_SESSION elements

Michael Southwell southwell at dneba.com
Fri Oct 24 15:22:33 EDT 2003


At 12:20 PM 10/24/2003, you wrote:
>Hi all,
>
>I'm trying to avoid a bunch of if/then statements by looping through 
>$_SESSION.  I hit a roadblock that I can't seem to get around.  Here is a 
>simple piece of code which I think gets to the heart of the problem:
>
>$begin=1;
>if(isset($_SESSION['$begin_fair_name']))
>{
>   echo "success";
>}

Aside from all the explicit advice you've gotten about how to handle this, 
make sure that "isset" is actually the test you want.  Check PHundamentals 
#2 at http://phundamentals.nyphp.org to see (or remember) just how 
complicated this might be.


>Of course, this works:
>if(isset($_SESSION['$1_fair_name']))
>{
>   echo "success";
>}
>
>BUT, I have between 1 and 10 fair_name fields (i.e. 1_fair_name, 
>2_fair_name) coming from the form.  It would be much more efficient if I 
>can loop through and perform operations as opposed to a bunch of if/then 
>statements referring to specific fair_name fields.  Obviously the problem 
>is with using a variable inside the array and I haven't been able to 
>figure out how to work around it.
>
>Trying to keep it brief here, but please let me know if further details 
>would be helpful.  I would appreciate any tips or suggestions.
>
>Thanks!
>
>-Aaron
>
>_______________________________________________
>talk mailing list
>talk at lists.nyphp.org
>http://lists.nyphp.org/mailman/listinfo/talk

Michael G. Southwell =================================
DNEBA Enterprises
81 South Road
Bloomingdale, NJ 07403-1419
973/492-7873 (voice and fax)
southwell at dneba.com
http://www.dneba.com
======================================================




More information about the talk mailing list