A research about Cookies and Session.pdf

Embed Size (px)

Citation preview

  • Nguyen Hoang Phuc ITITIU11008

    A research about Cookies and Session First thing first, we need to understand clearly about Cookies and Session. What we will be

    covering in this research:

    What is Cookie ?

    What is Session ?

    What is the difference between Cookie and Session"

    How to use Cookie ?

    How to use Session ?

    What is Cookie ?

    Cookie is not a cookie you eat, it is a tiny text file that store the info of user in their PC such as

    name, password, address, email, phone number

    Each time the internet browser interacts with a website it will pass the cookie to the website

    server. Only the cookies stored by the internet browser that relate to the domain in the

    requested link will be sent to the server.

    If user use the internet browser with Private Mode (Internet Explorer), Anonymous Mode

    (Firefox), Incognito Mode (Google Chrome) is on then any input will not be stored, its

    recommended when using a public computer.

    What is Session ?

    Same as cookie but the information will store on the website server. It has only a unique

    identifier is stored on the client side (called a "session id"). This session id is passed to the

    server every time the internet browser sends an HTTP request. The web app pairs this session

    id with internal database and retrieves the stored information for user by the requested page.

    What is the difference between Cookie and Session ?

    Cookies and session both store info about the user but the difference is that cookies store info

    on local computer - internet browser (we called is client-sided) and sessions store info on the

    cloud computer - website server (we called is server-sided). Cookie is limited in the storage

    and only stores limited content for each user while Session is not limit in such a way. You can

    delete a cookie manually by pressing Delete Cookies in the Settings menu of internet browser

    You also end a session by logging out of a website or pressing Delete Cookies - it also end

    session too

  • Nguyen Hoang Phuc ITITIU11008

    How to use Cookie ? How to use Session ?

    // index.jsp

    First Name: Last Name:

    Main.jsp shows how to retrieve the saved name. Cookies First Name: Last Name:

    // index.jsp

    What's your name?

    The target of the form is "SaveName.jsp" which saves the user name in the session Continue

    Result.jsp shows how to retrieve the saved name.

    Hello,