PHP - URL query string parameters vs session variables -


which more reliable, better , safer method use url variables passed different pages: 1). using session variables url parameters, or

2). regular query string parameters.

"more reliable, better, , safer" regard to: 1. preventing problems deriving client side, such when user disables cookies 2. browser compatibilities 3. making api calls (as api's have limitations , compatibility issues) 4. resource , memory usage, , processing speed

i'm creating site amount of query string parameters in urls may vary (potentially 9 values carried in url) - based on user input. seem easier store variable values in session variables carry of them (possibly 9) in url parameters. because of 4 concerns mentioned above, i'm hesitant use session variables.

thanks advice!

ps. url parameters being built dynamically $url variable, this:

$keyword = trim($_get["keyword"]);  $url = "webpage.php?"; $url .= "&keyword=$keyword";  $shopbystore = $_get["store"]; if (!empty($shopbystore)) { $url .= "&store=$shopbystore"; } // 7 more methods potentially retrieving values url parameters  

the url's this:

<a href="<?php echo $url; ?>">anchor text</a><br> 

and of course if go session variable route, user input values obtained url clicks , stored in session variables until session over.

if (isset($_get["store"])) { $_session["shopbystore"] = $_get["store"]; }   

of course possible save example submitted keyword search in session variable.

but useful? no.

the session variable forget everything, when session get's destroyed. maybe user wants save search or give them user?

with get-parameters not problem, copy full url , safe it.

but session parameters? not possible. each user has it's own session , next time user visits site, session (for example if users closed browser before).

in sessions should store user specific information. example userid, username or basket items.

that points session vs get.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -