Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I have a page where a user enters a search term, this then forwards to another page and runs a query based on this cookies contents. I was just wondering if it is good practice to do it this way? I know I can use a method="post (or get)" but I need the information to be consistent across several pages and queries.

share|improve this question

closed as off topic by Glenn Rogers, Jeff Vanzella, palacsint, svick, Brian Reichle Nov 7 '12 at 20:57

Questions on Code Review Stack Exchange are expected to relate to code review request within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

up vote 0 down vote accepted

Using a cookie sounds like the simplest way to achieve this, providing that users will have cookies enabled (and you'll also need to ask them, or at least inform, that you're using cookies).

Otherwise, if you wanted to keep a history of search queries, you could store them in a database (since you tagged mysql). This would obviously keep all search queries indefinitely, and would work for any users who didn't have cookies enabled.

share|improve this answer
thank you for your advice. in regards to storing these search queries, in what way could I go about calling all related search queries after the initial landing page has submitted that search data to the database? – Sam Street Nov 7 '12 at 16:08
If I'm following you correctly, it sounds like you already have users, which I would imagine are stored in the database. So you could store a users search queries with each user in the DB. That way, when a user is logged in and loads a specific page, you can also pull up any relevant search queries for that user. If you have any questions regarding the actual code for achieving this, I would recommend you ask on StackOverflow. – edparry Nov 7 '12 at 16:53
I already have users yes, but these users don't log in as this is based on an intranet site and people can just access the landing page where there is just a search box. You have a good idea and I will try implementing this into my work thank you. – Sam Street Nov 8 '12 at 8:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.