Question

I'm working on a small marketing project with Zend Framework, the backoffice of the project is currently made of two controller: a campaign controller and a minisite controller. The user create a campaign with a form, then he have to create a minisite with a second form linked to this campaign, so i need to get the campaign and the user id when saving the data of the minisite.

What is the best practice and why? should i pass those variables in a session object? or should i pass those variables through a route like :

/backoffice/minisite/create/:userid/:campaign/

Edit: users are logged and authenticated when creating campaigns

Was it helpful?

Solution

I'm pretty sure users need to have an account to do these things. If yes, there campaigns and minisites will be associated with them in some way. I'd store and retrieve these things from some form of database.

If you're not having authenticated users and you really just need to pass two variables to another action, use url parameters but be aware of the fact that users can mess with them and a lot of unexpected stuff can happen. Storing in the session is harder to manipulate in that way.

So, if no authentication is involved and the site is public, use the session, otherwise use neither but use storage.

OTHER TIPS

Assuming users have to be logged in to do this, you could store the user information you need in a Zend_Auth identity

If not, you could store the data in a normal session var with Zend_Session or redirect to with the route. Either option is good, so it's up to you to pick the one which best suits you and your application.

For passinf information between two controller the best way is to use session to store the values globally . :-)

I would use the route option, as you suggest. Using sessions is going to end up being very difficult to test, debug, extend in the future etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top