Java, .NET, PHP, PYTHON, ANGULAR, .NET, ML, Data Scince, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

What are Cookies in Java? Cookie Tutorials in JSP and Servlet 

Cookie:-

It is used to perform the Client-side state management process, a cookie is used to store server-side data under client machine for particular browser.

The cookie will be private because it will be stored on a particular browser under the operating system cookie folder which will be managed by a web browser separately.

When we create Session Data then the cookie will be created automatically.

Remember me option will be created by cookie.

Syntax to create cookie:-

Cookie ref = new Cookie(key,value);
ref.setMaxAge(time);
response.addCookie(ref);





Syntax to Get Data From Cookie:-


         Cookie c[] = request.getCookies();
            String s="",u="";
            for(int i=0;i<c.length;i++)
            {
                if(c[i].getName().equals("cuid"))
                {
                    s=c[i].getValue();
                }
                if(c[i].getName().equals("cpass"))
                {
                    u=c[i].getValue();
                }
            }
           

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post