# Set session on jQuery.load function

**URL:** <https://discuss.rubyonrails.org/t/set-session-on-jquery-load-function/64747>\
**Category:** rubyonrails-talk\
**Created:** [August 10, 2012, 8:03am UTC](https://discuss.rubyonrails.org/t/set-session-on-jquery-load-function/64747 "2012-08-10T08:03:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [August 10, 2012, 8:03am UTC](https://discuss.rubyonrails.org/t/set-session-on-jquery-load-function/64747/1 "2012-08-10T08:03:27Z")

</div>

Hi, I have a strange problem. Scenario: When loading an x page. I am making an ajax call in jQuery to server 'latest' action. Now, when I set a session in 'latest' action. To check check created session I made another ajax request to same 'latest' action.

Here created session is nil. code: --------------------------sample.js------------------------------ $("#latest\_activities").load("#{latest\_activities\_path}");

$('.get-activities').click(function(){ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//ajax request to latest\_activities\_path &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});

def latest &nbsp;&nbsp;p session['test'] &nbsp;&nbsp;session['test'] = 'test' end

I did got why it is not persisted.

Thanks, Aashish
