Forum Moderators: coopster

Message Too Old, No Replies

Which is faster Get or Session

         

BlackRaven

1:35 am on May 15, 2007 (gmt 0)

10+ Year Member



which of the if statements is faster,
note that the $_GET if statement does not need session_start()

if($_GET['member']==1)

or

session_start();
if(isset($_SESSION['member']))

eelixduppy

1:40 am on May 15, 2007 (gmt 0)



You probably won't even notice a difference in them, but I'd say the first example. The real question is, however, which one suits your needs better? This depends on what you are trying to do.

joelgreen

12:10 pm on May 15, 2007 (gmt 0)

10+ Year Member



Think first one is faster because second one has to run two more functions. But as eelixduppy said you may not even notice a difference.

Additionally session may expire, and _SESSION['....'] would not work, while $_GET['...'] will work :)

lorax

6:50 pm on May 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Partly depends upon the number of elements in each array. If you're carrying a lot of SESSION variables and only have a few GET vars then GET should be quicker. But as was pointed out, sometimes you need to use SESSION instead of GET for security and/or other reasons.