Results 1 to 2 of 2

Thread: [Java] Help Session Holding

  1. #1
    foreignemphasis's Avatar
    Joined
    Apr 2016
    Posts
    92
    Userbars
    1
    Thanks
    49
    Thanked
    14/11
    DL/UL
    52/0
    Mentioned
    10 times
    Time Online
    3d 13h 28m
    Avg. Time Online
    1m

    [Java] Help Session Holding

    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.

  2. #2
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m
    @(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

  3. The Following 4 Users Say Thank You to Zachafer For This Useful Post:

    foreignemphasis (05-25-2016),Ghosts (05-25-2016),j03 (05-25-2016),npm (06-27-2016)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •