Jump to content

Session Variables - Is there a smarter way to do this?


Recommended Posts

Im passing form values over to a confirmation page where Im setting session variables in order to allow the user to "go back" if they wish, to ammend their previous entries.

 

I just wanted to ask....this seems very cumbersome. Is there a smarter way to do this? Because I have about 50 values from the form.

$_SESSION['share_header'] = isset($_REQUEST["share_header"]) ? $_REQUEST["share_header"] : "";
$_SESSION['share_rent'] = isset($_REQUEST["share_rent"]) ? $_REQUEST["share_rent"] : "";
$_SESSION['share_bond'] = isset($_REQUEST["share_bond"]) ? $_REQUEST["share_bond"] : "";
$_SESSION['share_proptype'] = isset($_REQUEST["share_proptype"]) ? $_REQUEST["share_proptype"] : "";
$_SESSION['theDate'] = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : "";
$_SESSION['share_num'] = isset($_REQUEST["share_num"]) ? $_REQUEST["share_num"] : "";
$_SESSION['share_street'] = isset($_REQUEST["share_street"]) ? $_REQUEST["share_street"] : "";
$_SESSION['share_location'] = isset($_REQUEST["search"]) ? $_REQUEST["search"] : "";
$_SESSION['share_description'] = isset($_REQUEST["share_description"]) ? $_REQUEST["share_description"] : "";
Edited by ramone_johnny
Link to comment
Share on other sites

Then don't store those fields in the session, simple as that.  $_POST is an array.  Using countless techniques, you can filter out what you do not want.

 

The best strategy? Blacklists and Whitelists.

 

If you have more fields that you need to save than you do the fields you don't want to save, then create a blacklist for those you want to avoid storing

If you have more fields that you do not need to save than you do fields you want to save, then create a whitelist for those you do indeed want to store.

 

I'm not exactly sure how you're data look, so I can't exactly write out a blacklist/whitelist ad-hoc script for you.  Programming is a logic game, play it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.