0

How to perform any action after cookie load completed. e.g we have to redirect the url after cookie load complete.

$(document).ready(function() {  // Handler for .ready() called. });

We have cookie loaded after page load through javascript. So i dont have option but to wait till the cookie is completely loaded and page redirect.

Chitta Sukla
  • 63
  • 4
  • 9

3 Answers3

0

cookies are sent through HTTP headers, so you can load them anywhere and performs the redirect action in your page even on <head> block.

Here jQuery is not necessary, just execute a location.href = ...

Fabrizio Calderan
  • 120,726
  • 26
  • 164
  • 177
0

The cookies are sent in the response header (unless doing them after page load via javascript), so you don't even have to wait until document ready. You could make a javascript redirect be the very first content given to the browser, no need to wait for the page to load.

Through typically in such situations, you may just want to handle this whole thing on the server (i.e. not rely on javascript at all).

Mike Brant
  • 70,514
  • 10
  • 99
  • 103
0

You may try the following

<head>
  <script>
    if(condition){
      window.location = "http://yournewlocation.com";
    }
  </script>
</head>
Swadesh Behera
  • 927
  • 9
  • 13