tags:

views:

416

answers:

2

For a webapp written in Grails I would like to keep track of the current users account. In addition the account-name should be displayed as part of the url.

1) Keep the variable in the session 2) Pass the variable via account parameters

Currently I am experimenting with option 2 which allows me to create URL's like http://app.com/accountname/controller. The drawback is that with every URL I will have to pass the account name along as a variable. This is tedious and error prone.

Is any of the two options preferable? Are there better ways in Grails to achieve this?

Regards, Jens

A: 

A better way to keep track of the user is probably to set a cookie. It will be sent to the server with every request & you can easily read it. Why do you need the account name to be part of the URL? I can't think of a good reason to put the current users account in the URL. What happens when someone copy's & paste a link, and someone else follows it? Can you give some more details on what you're trying to do?

Bryan
Apologies if I did not describe clearly enough what I was looking to achieve. I would like to host multiple accounts within this application and was looking for the least intrusive way to do this. After a little more searching the web I found the multi-tenant plugin (http://grails.org/plugin/multi-tenant). It is still in early beta, but I will give it a go since it does exactly what I need.
jens
+2  A: 

I have been using a session variable to keep track of the user's account.

Ie: session.user = userAccount;.

You could set this in your login controller.

tegbains