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:
$(window).unload(function(){
if(location.href.indexOf(<my pages base url>) != -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 = <something new>;
.....
window.name = $.toJSON(cookie_alternative);
}
}
else{
//the user goes somewhere else
window.name = '';
}
});
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:
$('a').click(function(){
$.post({
url: $(this).attr('href'),
data: $.parseJSON(window.name).session_id,
})
})
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..
At the bottom of your page:
Maybe something like this will work?