How to LoginAndRedirect through Server Side Code

I am trying to create a widget that will allow users to login through our own user's validation. I followed the form authentication but it seems not able to signin automatically after I set the values on CSUserProfile.

Is there a way I can call LoginAndRedirect through server side code?