Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use $.post to be included in request of a new page
    primarykey
    data
    text
    <p>I'm working on cookie-free session, I dont intend to pass variables through URL, but I try to use window.name or hidden forms. For window.name, I'd do mosething like this:</p> <pre><code>$(window).unload(function(){ if(location.href.indexOf(&lt;my pages base url&gt;) != -1){ // the user is going to my site if($.parseJSON(window.name).previous_site.indexOf(location.protocol + '/' + location.host) != -1){ // now I know, that user was of my site cookie_alternative = new Object(); cookie_alternative.previous_site = location.href; cookie_alternative.session_id = $.parseJSON(window.name).session_id; // this is important ..... window.name = $.toJSON(cookie_alternative); } else{ // the user was elsewhere cookie_alternative = new Object(); cookie_alternative.previous_site = location.href; cookie_alternative.session_id = &lt;something new&gt;; ..... window.name = $.toJSON(cookie_alternative); } } else{ //the user goes somewhere else window.name = ''; } }); </code></pre> <p>So I can track session_id this way. I suppose I'd do something similar to this, if I was to use hidden input field. And now, I want this variable (session_id) from window.name to act as if it was cookies - user clicks on some link, which takes him to different part of my web => the request is sent to the server, server responds and page is displayed. With this request I want to send session_id to server using post (as if it was a cookie)- but I can't figure out, how to do this. I was thitking about something like this: </p> <pre><code>$('a').click(function(){ $.post({ url: $(this).attr('href'), data: $.parseJSON(window.name).session_id, }) }) </code></pre> <p>but I don't think it's going to work, and as I said, I'm not going to use URL rewriting. Other way to do this would propably be to have some hidden form type post, click on link sets form's action (href of a link), sets data: session_id and triggers form's action. Any ideas to send post to follow next pages request? Or how to use hidden form field to achieve the same thing? Any help really appreciated..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload