As we know , Cookie is a small piece of data which is sent from a website and stored in a user’s web browser while a user is browsing a website. Next time , when user browses , cookie can be retrieved . Cookies are essentially a token of string data that is stored on the user’s machine.
In this section , I will explain how easily you can play with cookies using Lift web framework and Scala language . Lift is an expressive and elegant framework for writing web applications. Lift provides its own Cookie support (rather than using underlying Servlet cookie support) . Using Cookies in Lift is very easy.
Add Cookie :
S.addCookie(HTTPCookie("cookie Name", "cookie Value").setDomain(S.hostName).setPath("/"))
Note: If you are trying to add a cookie with an existing cookie name , it will overwrite that cookie .
Delete Cookie :
Fetch Cookie :
If you want cookie with a given name :
If you want list of cookies , which will be sent in the response :