I'm new self-learning student, and my question is about the best system to make variables live during the process of the application.
<form action="<?=base_url; ?>detail/add_detail" method="POST">
<button class="submit">
<abbr title="Actualizar material"> <i class="fa fa-pencil"></i></button></abbr>
</button>
<input type="hidden" value="<?=$detail_data -> worksheet_id ?>" name="worksheet_id">
<input type="hidden" value="<?=$detail_data -> subcategory_id?>" name="subcategory">
<input type="hidden" value="<?=$detail_data -> detail_quantity?>" name="detail_quantity">
<input type="hidden" value="<?=$detail_data -> detail_price?>" name="detail_price">
<input type="hidden" value="<?=$detail_data -> detail_discount?>" name="detail_discount">
</form>
What I'm doing actually is, all the data from the inputs in the view, are sent by a post method with other variables like "I'd" in input type hidden, but I have to make this a lot of times during the change between view, controller, once in controller, I send them to the object and the object is sent to the model and then to the database. But carrying a lot of variables live, like Id to make the page working is a hell of a job, because every page you charge is a new page you need to give the variables for the while or name, etc. I'm asking what the best way is to do it and is not a smell code. –
For example:
1 - I can make variables live during the application using session [] and kill the variable when I don't need it.
2 - I can make an input type hidden and send it every submit. The problem is that every time I change the page, I have to do it again for a lot of variables, a lot of work every change of page.
Is there a problem to use a lot of session variables in terms of code smell?
How can I manage 6 or 7 variables every change of the page?