cart logic now ties cart with user when cart is created with logged in user

This commit is contained in:
Senad Uka
2015-03-15 04:53:04 +01:00
parent 8815267a79
commit 3b95500635
3 changed files with 29 additions and 23 deletions

View File

@@ -1,4 +1,22 @@
helpers do
def logged_in_user_id
auth = cookies['ribica_auth']
auth ||= -1
return auth.to_i
end
def anonymous_id
auid = cookies[:anonymous_user_id]
if auid.nil?
auid = AnonymousUser.uid
response.set_cookie('anonymous_user_id', :path=> '/', :httponly => true, :value=>auid, :expires=> Time.now + 100.year)
end
return auid
end
end
post '/user/logout' do
response.delete_cookie("ribica_auth", :path => "/")
end