Jump to content

Cookie array


rondog

Recommended Posts

I have an array of fields:

$fields = array(
	"cfg_change_date" => "Configuration Change Date",
	"system_name" => "System Name",
	"system_manf" => "System Manufacturer",
	"system_model_no" => "System Model Number",
	"system_serial_no" => "System Serial Number",
	"system_board_part_no" => "System Board Part Number",
	"system_board_serial_no" => "System Board Serial Number",
	"asset_tag" => "Asset Tag",
	"sla_code" => "SLA Code",
	"category" => "Category",
	"os_version" => "OS Version",
	"os_upgraded" => "OS Upgraded",
	"bios_version" => "BIOS Version",
	"bios_upgraded" => "BIOS Upgraded",
	"ilom_version" => "ILOM Version",
	"ilom_ip" => "ILOM IP Address",
	"ilom_updated" => "ILOM Updated",
	"rack_id" => "Rack ID",
	"rack_location_id" => "Rack Location ID",
	"tech_id" => "Tech ID",
	"warranty" => "Warranty"		
);

 

I have them all outputted as checkboxes right now in a form. When the user hits save, I want the checked ones to be stored in a single cookie and then later referenced so it remember what the user wants to query from the DB. The thing I cant figure out is how to do this dynamically rather than checking if each one is checked.

Link to comment
Share on other sites

ah ok I gotcha..I just did this and it it showing the checked ones

if (isset($_POST['saveFieldSelections']))
{
$checks = $_POST['checkboxes'];
if (isset($checks))
{
	while (list ($key,$val) = @each ($checks)) {
		echo "$val,";
	}
} 
}

 

Now my question is, should I just convert this to a string and store a long string? I would then explode() when I retrieved them. Does that sound about right?

Link to comment
Share on other sites

Ok I went ahead and used that method i described above and its kinda working. When I set my cookie, it seems the page doesn't recognize it til I refresh the page again. Like I have 3 boxed checked and check 2 more. After I hit the save, button the page does its thing, but I still only see 3 checked. If I refresh the page, they show all checked. Why is this?

Link to comment
Share on other sites

No, it's just that cookie data is not available until the next page load, hence the need for a redirect before you can use it. That's normal operation for cookies.

That's good to know. This is my first experience using cookies. Thanks guys.

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.