Login to stackoverflow.com via curl
Beside that using the api.stackexchange.com/docs/authentication would be the best solution your problem with the above curl statement is that you send a http post to the server without a body. So you should add something like:
-d "user=value1&passwd=value2"
Where user/passwd should be the field names of the login dialog here - also maybe the login form contains some hidden fields ... so you should analyse that first.Also keep in mind that you let curl write cookies into a file so that you could use them on later curl calls.