I want the session to be checked before sending a user to the login - whereby each URL request results in checking whether this is from a valid session - if not, send them to the login page, else process as normal. If the user already has an active session, we will not show them the login page but take them to a pre-defined main page.
I searched on google related to it, and come to know that it will done by using @Before
annotaion in controller but dont know about @Before
working and how to use? I'm using play 1.2.5.
The Play secure module does exactly that out of the box. It is used by most applications and integrates with different plugins as well. Check out the documentation here.
If you still want to implement it yourself you can use the secure code as an example.
Otherwise @Before can be used on any of your controller static methods and has access to all the scope Objects, including session.