Session, Cache OR Cookies which one to use to retain Search Criteria of User? (Posted With Case Study)
<p>I am developing a Web application which is based on ASP.NET 4.0, JQUERY, AJAX and Javascript. I have a particular search page in which a user can search via multiple factors i.e. either by Date, Name, Code, Category etc.</p>

<p>For e.g. </p>

<p>A) In a SearchProducts form, user can search a product via its unique Number OR Name OR Start Date/End Date OR Category OR etc etc. </p>

<p>B) User can search by either one or all of the parameters which a standard search form should be able to do.</p>

<p>C) If user searches via Start Date and End Date say 1st Dec 2012 to 31st Dec 2012 so for example my Search Results consist of 4 Products i.e. 4 products are purchased from 1st Dec to 31st Dec</p>

<p>D) Results are displayed in the grid and by clicking on the Product Number its redirecting to its View page (selected Product Specific full details) with ProductID via  Query string. </p>

<p>E) <strong>I have a requirement which enables the user to retain search results which he/she has searched via Back To Search button in View page (selected Product Specific full details) page</strong>.</p>

<p>Now, What I have planned is as follows:</p>

<p>1) <strong>When a user submits on the Search then I want to store the refference of Search Paramters i.e Date, Name, Category etc which user has entered.</strong></p>

<p>2) I will set a value in query string to differentiate normal request and request Via Back to Search button.</p>

<p>3) code in Search Page:</p>

<pre><code>       if (!(IsPostBack))
       {
          string tempRequestMode = string.Empty;

          if (Request.QueryString["requestMode"] != null)
          {
              tempRequestMode = Request.QueryString["requestMode"].ToString();

              if (tempRequestMode == "searchResults")
              {
                 //RestoreValues();
                 //Fetch results from the database again based on above results
              }
          }
       }
</code></pre>

<p>Now, My question is:</p>

<p>I wanted to use <strong>ASP.NET Cache</strong> for this purpose:</p>

<p><strong>Advantages</strong>: its expiration and dependencies</p>

<p><strong>Disadvantages</strong>: its has the application scope i.e. its not per user wise as Session is.</p>

<p>Second option is <strong>session</strong>:</p>

<p><strong>Advantages</strong>: its per user wise.</p>

<p><strong>Disadvantages</strong>: Session is more memory intensive.</p>

<p>I am confused that what Should I use. Is there any other option to use as <strong>Search Criteria is different for different users so want user wise maintenance of data</strong>.</p>
