if i have a search function for my site and i want the user’s former search preferences to be available at any page on my site where the search module is available all i can think of is to convert the $_POST variable to a cookie… but i am just modifying what was already constructed by another person whom i replaced, and i dont know if his other pages dependent on that search module would get affected if i started to rely on the cookie… so i was trying to create a persistent $_POST array from which i can work with.. is it possible?
if i have a search function for my site and i want the user’s
Share
I would look into using $_SESSION. Put all the search items into an array in $_SESSION.
to give you an example:
say a user searches for ‘apples’,
add it to $_SESSION[‘search_items’][] = ‘apples’;
say the user then searches for ‘oranges’,
add it to $_SESSION[‘search_items’][] = ‘oranges’;
make sure you have session_start(); at the top of every page you plan on using the search functionality. then you can add and access the search items in $_SESSION