how to check session with a filter?

Hey all,
I have a simple session checker function in my application.rb:
def check_session
unless !session[:state].nil?
redirect_to :controller => ‘users’, :action => ‘login’

I would like to apply that function to some actions only of my
‘machines’ controller which are edit,update,create,new and destroy. I
know it has something to do with before_filter but I’m not sure how to
use it.

any idea?

thanx in advance