Play framework many controllers (and session management)

matanster

For pure code organization purposes, I consider creating many controllers in my application. I found no special overhead created by a controller object. On a quick inspection of play's source, it does not seem to spawn any especially thick objects that would incur a lot of memory consumption per each controller.

However I wonder whether sessions seamlessly cross across controllers, or are they bound in some way to the boundaries of a controller. I also consider using secure social in case it matters.

Thanks!

Michael Zajac

There is no reason to think that sessions would not work seamlessly across different controllers. Play is designed to be as stateless as possible, so controllers shouldn't be keeping any sort of state that might make sessions behave differently.

For example, there is really no difference between:

object Users extends Controller {
    def read(id: Long) = Action { ??? }

    def create() = Action { ??? }
}

and

object ReadUsers extends Controller {
    def read(id: Long) = Action { ??? }
}

object CreateUsers extends Controller {
    def create() = Action { ??? }
}

Obviously, this isn't the ideal organizational structure we're looking for, but it conveys my point. Controllers should be organized in a manner that you think is best for your code. The only time session data might be treated differently is if your controller object mixes in different traits, or uses different Action types. I'm not very familiar with SecureSocial, but the choice of library shouldn't really be relevant.

Unless you are storing data in vars within a controller (or something similar), you should be okay.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do you change the Play 2.1! Framework session cookie name

From Dev

Clear session and redirect in same controller method (Play framework with scala)

From Dev

Problems with Scala Play Framework Slick Session

From Dev

Play framework handling session state

From Dev

Play Framework, REST, Routes, and Controllers

From Dev

Converting a Scala Session Object to a Java Session Object in Play Framework

From Dev

How do I handle a session timeout or expiration in Play Framework?

From Dev

InstantiationException for controllers in Play Framework after upgrading IntelliJ

From Dev

Unit Test controllers in Play 2 framework with Scala

From Dev

How to use Play Framework's request and session scope in Google Guice?

From Dev

Play Framework - Getting Session Data in Views

From Dev

Play framework: how to monitor number of active sessions with standard session API?

From Dev

Play Framework For Scala: Compilation error[type Application is not a member of package controllers]

From Dev

Unit testing controllers with ScalaTest in Play! framework

From Dev

Play Framework 2.4 don't accept "public static Result" for controllers

From Dev

Testing Controllers In Play Framework

From Dev

How can I perform session based logging in Play Framework

From Dev

How do I handle a session timeout or expiration in Play Framework?

From Dev

Unit Test controllers in Play 2 framework with Scala

From Dev

Play Framework - Getting Session Data in Views

From Dev

Play framework: Query string bases session if cookie are disabled

From Dev

Play Framework app can't be deployed when ssh session stopped

From Dev

scala play framework reverse routing and controllers

From Dev

Difference between Play Framework Session and PHP Session

From Dev

Play Framework - value login is not a member of controllers.Application

From Dev

remain logged in for whole session play framework (java)

From Dev

Testing Controllers In Play Framework

From Dev

How to Implement Session Timeout in play framework 2.2.5?

From Dev

How to use a controller inside a folder in the controllers folder with Play framework 1.4.3

Related Related

  1. 1

    How do you change the Play 2.1! Framework session cookie name

  2. 2

    Clear session and redirect in same controller method (Play framework with scala)

  3. 3

    Problems with Scala Play Framework Slick Session

  4. 4

    Play framework handling session state

  5. 5

    Play Framework, REST, Routes, and Controllers

  6. 6

    Converting a Scala Session Object to a Java Session Object in Play Framework

  7. 7

    How do I handle a session timeout or expiration in Play Framework?

  8. 8

    InstantiationException for controllers in Play Framework after upgrading IntelliJ

  9. 9

    Unit Test controllers in Play 2 framework with Scala

  10. 10

    How to use Play Framework's request and session scope in Google Guice?

  11. 11

    Play Framework - Getting Session Data in Views

  12. 12

    Play framework: how to monitor number of active sessions with standard session API?

  13. 13

    Play Framework For Scala: Compilation error[type Application is not a member of package controllers]

  14. 14

    Unit testing controllers with ScalaTest in Play! framework

  15. 15

    Play Framework 2.4 don't accept "public static Result" for controllers

  16. 16

    Testing Controllers In Play Framework

  17. 17

    How can I perform session based logging in Play Framework

  18. 18

    How do I handle a session timeout or expiration in Play Framework?

  19. 19

    Unit Test controllers in Play 2 framework with Scala

  20. 20

    Play Framework - Getting Session Data in Views

  21. 21

    Play framework: Query string bases session if cookie are disabled

  22. 22

    Play Framework app can't be deployed when ssh session stopped

  23. 23

    scala play framework reverse routing and controllers

  24. 24

    Difference between Play Framework Session and PHP Session

  25. 25

    Play Framework - value login is not a member of controllers.Application

  26. 26

    remain logged in for whole session play framework (java)

  27. 27

    Testing Controllers In Play Framework

  28. 28

    How to Implement Session Timeout in play framework 2.2.5?

  29. 29

    How to use a controller inside a folder in the controllers folder with Play framework 1.4.3

HotTag

Archive