# Can i store multiple values in session ? how?

**URL:** <https://www.ruby-forum.com/t/can-i-store-multiple-values-in-session-how/85024>\
**Category:** Rails\
**Created:** [February 9, 2007, 11:24am UTC](https://www.ruby-forum.com/t/can-i-store-multiple-values-in-session-how/85024 "2007-02-09T11:24:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![truptibhatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@truptibhatt](https://www.ruby-forum.com/u/truptibhatt)\
**Post date:** [February 9, 2007, 11:24am UTC](https://www.ruby-forum.com/t/can-i-store-multiple-values-in-session-how/85024/1 "2007-02-09T11:24:38Z")

</div>

hi,

i m calling following method on " onclick " event of checkbox and i m  
getting id of all selected checkboxes, but now i want to store multiple  
ids to store in session , can i? or any other options?

def checksel  
@data=""

data = params[:p\_id]  
stat=params[:stat]

if stat==“true”  
@tmp = data

end  
end

---

<div class="post-metadata">

**Author:** ![truptibhatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@truptibhatt](https://www.ruby-forum.com/u/truptibhatt)\
**Post date:** [February 9, 2007, 12:00pm UTC](https://www.ruby-forum.com/t/can-i-store-multiple-values-in-session-how/85024/2 "2007-02-09T12:00:08Z")

</div>

‘The easy way is to concatenate the ids and store in the session  
variable’

---

<div class="post-metadata">

**Author:** ![truptibhatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@truptibhatt](https://www.ruby-forum.com/u/truptibhatt)\
**Post date:** [February 9, 2007, 12:31pm UTC](https://www.ruby-forum.com/t/can-i-store-multiple-values-in-session-how/85024/3 "2007-02-09T12:31:23Z")

</div>

On Feb 9, 5:24 am, Trupti B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> stat=params[:stat]
> 
> if stat==“true”  
> @tmp = data
> 
> end  
> end
> 
> –  
> Posted viahttp://www.ruby-forum.com/.

You can store all kinds of stuff in a session, but it will all get  
stored on your disk or wherever your sessions are stored and could  
take up alot of space if you don’t clear it out over time.

suppose myrec was an array of some kind of records. You could store as  
many as you like in the session:

myid = :‘id432343’  
@session[myid] = myrec[0]  
myid = :‘id432343’  
@session[myid] = myrec[1]

…  
…
