the "gpc" part of "magic_quotes_gpc" stands for Get, Post, and Cookie; so no, it does not affect sessions. 🙂
I just put everything in a function to make it portable: you can put it in an include file of other functions, etc., and then just call it from your main script. But if you want to use it differently, by all means do what works for you; e.g., just copy everything between the function definition curly braces, and paste it into your config.php script if you use one, for example.