app/controllers/application_controller.rb
## Session/Cookie management :D 
Session/Cookie management :D
Session / Cookie management : D
def sesh(name, value=nil)
    unless name.is_a? Symbol
      name = name.parameterize.underscore.to_sym
    end
    unless cookies.has_key?(:sesh_id)
      @sess = Storage.new
      @sess.data = {}.to_json
      @sess.save
    end
    unless defined? @sess 
      @sess = Storage.find(cookies[:sesh_id])
    end
    data = JSON.parse(@sess.data, :symbolize_names => true)
    unless value.nil? 
      data[name] = value
      @sess.data = data.to_json
      @sess.save
    end 
    cookies[:sesh_id] = @sess.id
    data[name]
  end
def sesh ( name , value = nil ) unless name . is_a? Symbol name = name . parameterize . underscore . to_sym end unless cookies . has_key? ( :sesh_id ) @sess = Storage . new @sess . data = { } . to_json @sess . save end unless defined? @sess @sess = Storage . find ( cookies [ :sesh_id ] ) end data = JSON . parse ( @sess . data , :symbolize_names => true ) unless value . nil? data [ name ] = value @sess . data = data . to_json @sess . save end cookies [ :sesh_id ] = @sess . id data [ name ] end
Session/Cookie management :D
Session / Cookie management : D
name
<not_specific>
value
<not_specific>