Apologies for running into the old thread, but it's good that this data was updated on the previous saimeunt answer, now deprecated, since this.location.path no longer exists in the Iron Router, so it should look something like this:
Router.onStop(function(){ Session.set("previousLocationPath",this.originalUrl || this.url); });
Or if you have a JSON session (see Session JSON )
Router.onStop(function(){ Session.setJSON("previousLocationPath",{originalUrl:this.originalUrl, params:{hash:this.params.hash, query:this.params.query}}); });
Only reservations with thisis that the first page will always fill url fields (this.url and this.originalUrl, there seems to be no difference between them) with the full url ( http: // ... ), While each the next page registers only the relative domain, i.e. / home without a root url, not sure if this is the intended behavior or not from IR, but this is currently a useful way to determine if this was the first page load or not
source share