0
I have a question about the use of sectionals. I’m building a dynamic query system to get data from my database when I click on a link, each link passes an id through the URL. On the page where the magic happens, I take the ID by the _GET method and pass it via _SESSION to the "process" page to pick it up and list which products belong to the "x" ID. But when I open two links at the same time, when I use the field to search dynamically, one ends up searching the id of the other. For example:
I opened the link where it should show me items with ID 1, minimized this window and then opened another link with ID 2, then maximize the 2 windows (browser) and search in the window that listed items with ID 1 and ends up showing me items with ID 2 (which he had to keep showing me with ID 1).
I know it’s a little complicated to explain and you understand but, I’ll try to improve by adding the following photos:
I wanted each of you, when you clicked on the link, to open your own Ssion, so I guess you wouldn’t have this problem anymore.
That’s not what Serssion’s about. I constantly see here on the site the people wanting to store everything in Session, and pass things between pages by Session. To pass things between pages usually use POST, GET, etc and not Session. The Session can even serve as a temporary basis, but needs to link to a specific ID each desired group.
– Bacco
That’s it, I have to pass the id to the other page "processes" and the POST method would have to have a certain Submit? I would like to do dynamic.. something like "Submit onkeyup" in the input field.
– brnTwp
Store each thing of each ID in a separate structure. Be it DB, be it ;txt, be it cookie or Session, you need to sort by subject. For example, (taking advantage of Session, just not to throw everything you’ve done away), instead of $_SESSION['list'] using $_SESSION['list'][$id_da_unit] or something like that (even so, I think Session sucks, because if the person loses the connection, they have to start from scratch). Now, if it’s something between pages, go through POST or GET.
– Bacco
I have no problem dismantling, I don’t have much programming knowledge, I know the basics. But if there are possibilities of a GET, POST, without a Ubmit (give a refresh on the page in case) could try using this method.
– brnTwp
And the fact of being dynamic or not independent of it. It has how to use POST dynamically, or even by AJAX.
– Bacco
The important thing is to understand the pros and cons of each method. Session is a good ally as long as you understand what it is and especially what it is not. The name says it all, it is for things relating to the current session (something like an uninterrupted sequence of operations of the same user, for a certain period of time). One of its effects is that several tabs in the same browser (in normal use) are part of the same Session. That is, you need to create your own mechanism to manage tabs individually (tab id, or tab db + id, that id passed by get, post, or part of the url)
– Bacco
I got it, there would be some example of this GET, POST method that fits more or less in my proposal for me to try?
– brnTwp
Example: instead of /editarItens the path would be /editarItens? department=laboratory and you would use the variable $_SESSION['items'][$department] to store the items, and not just $_SESSION['items'], so for each $department (obtained with $GET) you have a separate list - still in Session, but separated by department. But don’t cling to that idea, every case is a case.
– Bacco
I get it. I was thinking about maybe passing the department ID in a field Hidden input with dynamic Submit with ajax to pick up via GET on the processing page, maybe I’ll get what I want.. because I need to specify in the query that I want items from certain department, if not it lists me all items
– brnTwp