     @user = null
     @create (err, new_session) -> cb(null, new_session)    
   
-  setUserAndAttributes: (id, user_data) ->
-    return null if id is undefined or user_data is undefined
-    R.hset @key(), 'user_id', id
+  setUserAndAttributes: (user_id, user_data) ->
+    return null if user_id is undefined or user_data is undefined
+    R.hset @key(), 'user_id', user_id
     @assignUser(user_data)    
-    R.hset @key(), 'attributes', JSON.stringify Object.extend @getAttributes(), user_data # Set attributes    
+    R.hset @key(), 'attributes', JSON.stringify(Object.extend(@getAttributes(), user_data)) # Set attributes    
     
   getAttributes: ->
     attr = R.hget @key(), 'attributes'
-    JSON.parse if attr is undefined then '{}' else attr+    JSON.parse(attr || '{}')
utils = require('./utils')

class exports.Session
  

  # Users
  assignUser: (data) ->
    return null unless data.user_id
    @user = new UserSession(data.user_id, @)
    @user.attributes = JSON.parse(data.attributes) if data.attributes

  loggedIn: ->
    @user?
