1

On a default search page, I have a login javascript that switches to a different search page after a successful login. However, if a user has already performed a search, I want that search string to carry over to the logged in page. In other words, how do I save my search string from one page to the next? Here is the current version of the script:

function customJavaScript() {
    jQuery(document).ready(function() {
        checkLogin();
    });
}
function checkLogin() { 
    if(com_sirsi_ent_login.isLoggedIn!==false) { 
        window.location.assign("/client/employee/search/results?te=ILS&dt=list"); 
    } 
}

2 Answers2

0

You could save the search string in localStorage or a Cookie, then load it upon successful login. Here's a great breakdown of the difference between the two.

Community
  • 1
  • 1
kneeki
  • 2,444
  • 4
  • 17
  • 27
  • But if I want to change my logged-in page url from, say, this [http://myserver/client/default/search/results?qu=radar&te=ILS] to this [http://myserver/client/employee/search/results?qu=radar&te=ILS] can I really do that with a cookie? Could I use a regex to simply replace "default" with "employee"? – Thomas Shepard May 04 '15 at 16:31
  • Yeah. If, for example you wanted to use localStorage, just do this when they perform a search: `localStorage.setItem("query", $("#queryInput").val());`, then once they log in, you can get their last query using: `localStorage.getItem("query");`. – kneeki May 04 '15 at 16:46
0

You could use local storage. It's similar to Cookies, you save your stuff locally in the Browser. The storage is accessible for all pages on the domain.

For more Information see: http://www.w3schools.com/Html/html5_webstorage.asp

curlyFoo
  • 1
  • 1