Session Variables Question

0 views
Skip to first unread message

Cecil Champenois

unread,
Aug 19, 2010, 11:33:40 AM8/19/10
to PHP Group
In the Zend PHP Certification Praxctice Test Book, on page 50, there is a question that doesn't seem to jive with the book titled PHP and MySQL Web Development.
 
The question is:
 
How are session variables accessed?
A. Through $_GET
B. Through $_POST
C. $_REQUEST
D.  Through global variables
E. None of the above
 
In the PHP and MySQL book, on page 513, there is a topic titled, "Using Session Variables" where it goes on to talk about how you do use the session variables.
 
Okay, so which is it?
 
Does the PHP Exam still choose answer E as stated in the Zend PHP Exam book?
 
Cecil

Heath Aiken

unread,
Aug 19, 2010, 11:38:24 AM8/19/10
to professi...@googlegroups.com
The answer is D, though a little clarification is in order.  $_SESSION is an automatic global variable meaning that you don't declare it as global, it just IS.

- Heath



--
This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.
 
For information or project assistance please visit :
http://www.360psg.com
 
You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
To post to this group, send email to Professi...@googlegroups.com
To unsubscribe from this group, send email to Professional-P...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Professional-PHP

Cecil Champenois

unread,
Aug 19, 2010, 11:43:21 AM8/19/10
to professi...@googlegroups.com
Here is the answer the Zend PHP Exam book gives:
 
Although session data can be accessed using the global variables if the register_globals INI setting is turned on, the exam uses a version of PHP configured using the default php.ini file found in the official PHP distribution. In recent versions of PHP, the register_globals setting is turned off by default because of its serious security implications. As a result, answer E is correct (none of the above).
 
I can guarantee you that everyone is going to have a different opinion on this. And, this Zend PHP Exam prep book is old now, printed in January of 2005.
 
Cecil



From: Heath Aiken <heath...@gmail.com>
To: professi...@googlegroups.com
Sent: Thu, August 19, 2010 8:38:24 AM
Subject: Re: [Pro. PHP Dev.] Session Variables Question

abinash grahacharya

unread,
Aug 19, 2010, 11:48:43 AM8/19/10
to professi...@googlegroups.com
yes you are right $_SESSION is it self a global variable but the question is "How are session variables accessed?"

It is not asking session is a global variable or not ? it is a global variable but accessing a global variable and accessing a SESSION variable is different
session variable is only can accessed by $_SESSION['variablename']

So on my point of view answer is E none of above

Thanks
Abinash

Heath Aiken

unread,
Aug 19, 2010, 12:24:59 PM8/19/10
to professi...@googlegroups.com
I should have interpreted the question a little better, but the question is misleading (IMO).  The question shouldn't be further clarified in the explanation of the answer...  Unless somewhere before the question (in the exam) they explicitly state that register_globals is set to off?

I haven't taken the Zend Cert exam, but if this is how they structure the questions / answers, it's going to be a headache...

But to your assertion that a session variable can only be accessed by $_SESSION['key']: this is true if register_globals is off, but if it is on, you can also access $_SESSION['key] by using $key.

Set your php.ini to register_globals = On

Do the following:
<?php
session_start();

$_SESSION['test'] = 42;
echo $test;

?>

You should see "42" echoed back. 

Now, I would NEVER do this in my code, and register_globals is off by default, but in my mind, this question should have clarified by saying "How are Session Variables accessed, assuming best / safe practices".

Maybe I'm missing something though, I'm doing like 4 things at once...

--Heath

Cecil Champenois

unread,
Aug 19, 2010, 12:32:58 PM8/19/10
to professi...@googlegroups.com
Yeah, I'd have to agree with you, Heath that the quesiton is misleading, kind of like a political argument where all the facts are not known, or are not discussed fully.
 
Cecil


Sent: Thu, August 19, 2010 9:24:59 AM

Subject: Re: [Pro. PHP Dev.] Session Variables Question

Robert Gonzalez

unread,
Aug 19, 2010, 12:56:26 PM8/19/10
to professi...@googlegroups.com
I took, and passed. the exam two years ago. Most of the questions are like this. Remember that the answer they want is the one that makes the most sense, not necessarily "the right" answer. I know that is counter intuitive, but really, that is how the test goes.

And for the record, if you want the hands-down best book on taking and passing the test, buy (yes, I said buy) Davey Shafik's Zend PHP5 Certification Study Guide. By far this is the best study guide you can find (he was part of the advisory team that assembled the PHP5 certification course).

Something else to remember... developers that have used PHP in real life situations are far more likely to pass this exam than folks that read a book. Since you will be tested on literally every major aspect of PHP there is no amount of reading that is going to prepare your for the questions you will face on the exam. Seriously, you will see questions about syntax, string functions, regular expressions, arrays, objects (PHP5 objects), references, streams, file handling, PHP settings, security... it's all in there. So whatever time you will spend studying I say devote as much time, if not more, to actual coding and testing. It will be entirely more valuable than reading a book when it comes to taking the test.

Oh, and lastly, try not to think of it as a test. If you are not a good test taker then no matter how good you are at PHP you will choke. I've known guys that are bad ass developers and who really know their craft not pass this test because they think themselves out of the right answers. Go with your gut, don't overthink and read each question as though you were the PHP engine.

Heath Aiken

unread,
Aug 19, 2010, 1:24:24 PM8/19/10
to professi...@googlegroups.com
Thanks for the insight Robert, your take on the certification is very helpful.  When considering that the test is designed for programmers, it definitely seems like a bad move to introduce any gray-area into the "correct" answer.  When I take the exam, though, I'll take your advice to heart.

I'm a self-taught, PHP lone-wolf developer, so I was planning on taking the exam to see where I am at as I have no peers (or managers) to compare my skills / knowledge against where I work.  There are a few areas that I need to brush up on, but I'll take your advice and do some practical application rather than just reading.

--Heath

Robert Gonzalez

unread,
Aug 19, 2010, 1:39:11 PM8/19/10
to professi...@googlegroups.com
Forgot to answer this question... the answer on the exam would be E. :)

abinash grahacharya

unread,
Aug 20, 2010, 7:51:14 AM8/20/10
to professi...@googlegroups.com
Hi

I am also preparing for ZEND certification last 6 month
Few things we need to remember in the exam

Till today no one know is there -ve mark or not
Output of the exam is pass or fail not any %
What is the pass mark no one knows
Questions itself hides the answer and there is a or more answers in options
There is answer and that is in front of you in with every question and you need to find out
If you are thinking this is the answer - then proof again and again that that is the answer
Think at least 10 times while giving the answer

you can have a mock test at http://doskyweb.com/skilltest i have created this application for zend test please go for that
Reply all
Reply to author
Forward
0 new messages