FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Session variables versus page variables





RT Cunningham
I'm looking for an opinion or two. I'm working on a project that reloads variables from the index page each time a header redirect takes you there. It works well, but my question is whether it would be faster or more economical to pre-load the session variables at the beginning and call the variables from there as opposed to reloading the variables from the page itself?

The reason I ask is because some of the variables have to be defined in advance to have default values. The page code consists of something like "if ($var == "") $var = "word";". I'm guessing it would be more economical to load the values from a session because the initial evaluation would never need to be repeated. Am I wrong?
manum
i guess sessions are a better choice in this sort of condition
sonam
I am prefer if statment with one reason. For example if you start session on page A and define $_SESSION[$war]= word; you can call this session on page B. But what hapend if someone come directly on your page B. In that case you haven't defined $war session. Then you again need if statment
Code:
if($_SESSION[$war]=="") {$_SESSION[$war]= word;}


Sonam
RT Cunningham
Entering from a page where the session variable is not defined is easy to eliminate. In fact, my script counts on that in order to operate properly. So the if/then/else issue isn't really an issue.

Did I make sense? It's 1 am here.
ALostSoul
RT Cunningham wrote:
I'm looking for an opinion or two. I'm working on a project that reloads variables from the index page each time a header redirect takes you there. It works well, but my question is whether it would be faster or more economical to pre-load the session variables at the beginning and call the variables from there as opposed to reloading the variables from the page itself?

The reason I ask is because some of the variables have to be defined in advance to have default values. The page code consists of something like "if ($var == "") $var = "word";". I'm guessing it would be more economical to load the values from a session because the initial evaluation would never need to be repeated. Am I wrong?



I'd say Sessions, they're easier.
Related topics
How To : Secure Your PHP Website
PHP Sessions
Need Help in PHP
PHP login/logout problem
Can l get my web site to have a shared login?
Problem with session variables
Why some script tags must put in the head of document?
php SESSIONS question
WeBot, I need feedback!
Scroogle
one line securing of php pages (login of users) (user auth)
$_COOKIE and $_SESSION help needed!
How to make Global Variables with PHP?
session variables
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.