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
https://forums.phpfreaks.com/topic/214334-cookie-array/
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
https://forums.phpfreaks.com/topic/214334-cookie-array/#findComment-1115381
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
https://forums.phpfreaks.com/topic/214334-cookie-array/#findComment-1115387
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.