title: Creating a session cookie inside a controller
body: <p>I'm new to Tomcat, servlets and Spring Web. I'm coming from a PHP background so I'm a little disoriented to say the least. I want a controller to create a session cookie for me.</p>
  
  <p>I've been told that I can get the session like this in a standard servlet:</p>
  
  <pre><code>protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
    // Somewhere inside the method...
    HttpSession session = request.getSession(true);
  
    // Set a cookie
        session.setAttribute("hello", "world");
  
    // More stuff...
  }
  </code></pre>
  
  <p>How does this translate into the Spring Web MVC way of doing things? Can I create session cookies inside a controller?</p>