Welcome to WebmasterWorld Guest from 54.158.143.40

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Which is faster Get or Session

   
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']))

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

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



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.
12:10 pm on May 15, 2007 (gmt 0)

5+ 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 :)

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

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 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.