AJAX form validation

I am making simple login form with…

if session[:user] = User.authenticate(params[:user][:login],
params[:user][:password])
render :update do |page|
page.redirect :action => ‘index’
end
end

in controller but this doesnt seem to work