Hi guys, i'm looking to learn how to program a neopets program in java. But i've got no clue how to hold a login session.
Any help? A demo and/or sample codes perhaps. I actually dun even know how to grab and request html pages. Lol so some help in that wld be nice.
I've only ever programmed in java for stand-alone applications processing data grabbed from ftp servers. I've no experience with programming for browser games.
@(you need an account to see links) Session holding is all done by cookies. Cookies are stored locally and are sent to the server with each webrequest. The server will tell you in its response what the cookie values should be.
For example, when you login to Neo, you send a POST request containing the data username=MUNSTERPOO&password=SECUREDPASSWORD with the account's username and password. Neo's server will respond with either a success or some kind of failure message. In the case of a successful login, the response headers will have lines that look like Set-Cookie: neologin=3021e68df9a7200135725c6331369a22; or Set-Cookie: np_uniq=munsterpoo_id_8514; to indicate which account session you are connected with.
Since this process is repeated with every request, it's smart to keep all the HTTP web handling in a seperate class to keep your code efficient. Check out this great post by @(you need an account to see links) that has a Java Connection class to act as a wrapper class - (you need an account to see links)
Keep asking questions, we like to help around here
Underlined words = key vocab words
The Following 4 Users Say Thank You to Zachafer For This Useful Post: