user1372212
user1372212

Reputation: 393

pass array to template file via include

I'm working on a company intranet system and have a function to load a form via include while passing an url encoded array in GET format

$draftcook = urlencode(serialize($draft));
include(FORM_PATH .'newrangesubtypeform.php?draft=yes&type='.$value.'&draftcook='.$draftcook);

Unfortunately my array has gotten too long to be able to be passed via a url, I have tried many other alternatives, including setting the array into a session variable and then pulling it through in the included form but that for some reason is unable to see the session variable.

Could someone please suggest a work around for this situation, the array itself is likely to have upward of 1000 fields in it by the time the whole page is completed if that effects the solution.

Thanks

Upvotes: 0

Views: 252

Answers (2)

Erik
Erik

Reputation: 1057

Included code runs in the same scope as wherever you called include. I'm not even sure why you're passing this stuff info the new file; any variable that exists can be used in the include.

So you can access $draft as a regular variable already.

Upvotes: 1

You can write into db or file a threat (id, draftcook) and pass the PK of the threat vía URL and then get the draftcook

Upvotes: 1

Related Questions