I managed to make it work.
What I was doing is replacing the javascript in page2 by my own code in my program, since the modem can't run javascript. And used the result and sent it to page3. This is fine but I actually wasn't making a HTTP request to page2.
If I request the three pages in the right sequence, replicating the functions that the javascript did in my own code and save the cookies, after page3 I receive a redirect to the desired web page and doesn't redirect again like it used to. I figured since I did everything page2 did I really didn't need to make a request and just skipped to page3. But for some reason I do, I dunno why, maybe the asp session actually starts on that page and doesn't show on the page source code or the server monitors the page request. And I didn't even understand why the operator needs to do this, I think it might even break HTTP connections from old cellphones cause it isn't really designed for devices that can't run javascript.
Next time I will just use a different operator =p
Thanks to Charles Forsythe for the tips and help.