diff --git a/httplite/minimum/pom.xml b/httplite/minimum/pom.xml
index e42cc38..f3f3833 100644
--- a/httplite/minimum/pom.xml
+++ b/httplite/minimum/pom.xml
@@ -78,7 +78,7 @@
 				</includes>
 			</resource>
 		</resources>
-		<plugins>
+		<plugins>			
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-compiler-plugin</artifactId>
diff --git a/httplite/minimum/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java b/httplite/minimum/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java
index 45dd509..6f97b98 100644
--- a/httplite/minimum/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java
+++ b/httplite/minimum/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java
@@ -60,7 +60,8 @@
     private boolean m_getOutputStreamCalled = false;
     private boolean m_getWriterCalled = false;
     private ServletOutputStreamImpl m_servletOutputStream;
-    private PrintWriter m_servletPrintWriter;
+    private PrintWriter m_printWriter;
+    private List m_cookies = null;
 
     private int m_statusCode = HttpURLConnection.HTTP_OK;
     private String m_customStatusMessage = null;
@@ -97,6 +98,20 @@
         }
 
         m_out.write(buildResponse(m_statusCode, m_headers, m_customStatusMessage, null));
+        
+        if (m_cookies != null)
+        {
+            m_out.write( "Set-Cookie: ".getBytes() );
+            for (Iterator i = m_cookies.iterator(); i.hasNext();)
+            {
+                Cookie cookie = (Cookie) i.next();
+                m_out.write( cookieToHeader(cookie) );
+                
+                if (i.hasNext()) {
+                    m_out.write( ';' );
+                }
+            }
+        }
         m_out.write(HttpConstants.HEADER_DELEMITER.getBytes());
         m_out.flush();
 
@@ -248,7 +263,7 @@
         }
         else if (m_getWriterCalled)
         {
-            m_servletPrintWriter.flush();
+            m_printWriter.flush();
         }
 
         if (!m_headersWritten)
@@ -338,13 +353,13 @@
             throw new IllegalStateException(
                 "getOutputStream method has already been called for this response object.");
 
-        if (m_servletPrintWriter == null)
+        if (m_printWriter == null)
         {
             m_buffer = new ByteArrayOutputStream(m_bufferSize);
-            m_servletPrintWriter = new PrintWriter(m_buffer);
+            m_printWriter = new PrintWriter(m_buffer);
         }
 
-        return m_servletPrintWriter;
+        return m_printWriter;
     }
 
     /* (non-Javadoc)
@@ -365,7 +380,7 @@
             throw new IllegalStateException("Response has already been committed.");
         }
         m_buffer.reset();
-        m_servletPrintWriter = null;
+        m_printWriter = null;
         m_servletOutputStream = null;
         m_getOutputStreamCalled = false;
         m_getWriterCalled = false;
@@ -385,7 +400,7 @@
         }
 
         m_buffer.reset();
-        m_servletPrintWriter = null;
+        m_printWriter = null;
         m_servletOutputStream = null;
         m_getOutputStreamCalled = false;
         m_getWriterCalled = false;
@@ -450,7 +465,15 @@
      */
     public void addCookie(final Cookie cookie)
     {
-        throw new UnimplementedAPIException();
+        if (m_cookies == null)
+        {
+            m_cookies = new ArrayList();
+        }
+        
+        if (!m_cookies.contains( cookie ))
+        {
+            m_cookies.add( cookie );
+        }        
     }
 
     /* (non-Javadoc)
@@ -729,6 +752,30 @@
 
         return buffer.toString().getBytes();
     }
+    
+    /**
+     * Convert a cookie into the HTTP header in response.
+     * 
+     * @param cookie Cookie
+     * @return String as byte array of cookie as header
+     */
+    private byte[] cookieToHeader( Cookie cookie )
+    {
+        if (cookie == null || cookie.getName() == null || cookie.getValue() == null) 
+        {
+            throw new IllegalArgumentException( "Invalid cookie" );
+        }
+        
+        StringBuffer sb = new StringBuffer();
+                
+        sb.append( cookie.getName() );
+        sb.append( '=' );
+        sb.append( cookie.getValue() );
+        
+        //TODO: Implement all Cookie fields
+            
+        return sb.toString().getBytes();
+    }
 
     /**
      * Append name and value as an HTTP header to a StringBuffer
diff --git a/httplite/minimum/src/test/java/org/apache/felix/httplite/osgi/test/cases/TestCookies.java b/httplite/minimum/src/test/java/org/apache/felix/httplite/osgi/test/cases/TestCookies.java
new file mode 100644
index 0000000..418541d
--- /dev/null
+++ b/httplite/minimum/src/test/java/org/apache/felix/httplite/osgi/test/cases/TestCookies.java
@@ -0,0 +1,208 @@
+package org.apache.felix.httplite.osgi.test.cases;
+
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.util.List;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.felix.httplite.osgi.test.AbstractHttpliteTestCase;
+import org.osgi.service.http.HttpService;
+import org.osgi.service.http.NamespaceException;
+
+
+/**
+ * Test that servlet container handles cookies correctly.
+ *
+ */
+public class TestCookies extends AbstractHttpliteTestCase
+{
+    private static final int MODE_NONE_SET = 1;
+    private static final int MODE_SIMPLE = 2;
+    private static final int MODE_MULTI = 0;
+
+
+    //TODO: Test cookie expiration
+
+    /**
+     * Test that no cookies are sent by default.
+     * 
+     * @throws ServletException
+     * @throws NamespaceException
+     * @throws IOException
+     */
+    public void testNoCookiesSentByDefault() throws ServletException, NamespaceException, IOException
+    {
+        HttpService httpService = getHTTPService( registry.getBundleContext() );
+        CookieServlet servlet = new CookieServlet( MODE_NONE_SET );
+        httpService.registerServlet( "/test", servlet, null, null );
+
+        //Test that no cookies are currently set.
+        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );
+
+        client.connect();
+        assertTrue( client.getResponseCode() == 200 );
+
+    }
+
+
+    /**
+     * Test creating and sending one cookie.
+     * 
+     * @throws ServletException
+     * @throws NamespaceException
+     * @throws IOException
+     */
+    public void testSimpleCookie() throws ServletException, NamespaceException, IOException
+    {
+        HttpService httpService = getHTTPService( registry.getBundleContext() );
+        CookieServlet servlet = new CookieServlet( MODE_SIMPLE );
+        httpService.registerServlet( "/test", servlet, null, null );
+
+        //Test that no cookies are currently set.
+        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );
+
+        //Set the cookie in the response
+        client.connect();
+        assertTrue( client.getResponseCode() == 200 );
+        assertNotNull( client.getHeaderFields().get( "Set-Cookie" ) );
+        List l = ( List ) client.getHeaderFields().get( "Set-Cookie" );
+        assertTrue( l.contains( "testcookie=testvalue" ) );
+
+        for ( int i = 0; i < 10; ++i )
+        {
+            //Confirm the cookie in the request
+            client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );
+            client.addRequestProperty( "Cookie", "testcookie=testvalue" );
+            client.connect();
+            assertTrue( client.getResponseCode() == 200 );
+        }
+
+    }
+
+
+    /**
+     * Test sending and recieving multiple cookies.
+     * 
+     * @throws ServletException
+     * @throws NamespaceException
+     * @throws IOException
+     */
+    public void testMultipleCookies() throws ServletException, NamespaceException, IOException
+    {
+        HttpService httpService = getHTTPService( registry.getBundleContext() );
+        CookieServlet servlet = new CookieServlet( MODE_MULTI );
+        httpService.registerServlet( "/test", servlet, null, null );
+
+        //Test that no cookies are currently set.
+        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );
+
+        //Set the cookie in the response
+        client.connect();
+        assertTrue( client.getResponseCode() == 200 );
+        assertNotNull( client.getHeaderFields().get( "Set-Cookie" ) );
+        List l = ( List ) client.getHeaderFields().get( "Set-Cookie" );
+        assertTrue( l.contains( "testcookie=testvalue;testcookie2=testvalue2" ) );
+
+        for ( int i = 0; i < 10; ++i )
+        {
+            //Confirm the cookie in the request
+            client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );
+            client.addRequestProperty( "Cookie", "testcookie=testvalue;testcookie2=testvalue2" );
+            client.connect();
+            assertTrue( client.getResponseCode() == 200 );
+        }
+
+    }
+
+    /**
+     * Servlet to test cookie support.
+     *
+     */
+    private class CookieServlet extends HttpServlet implements Servlet
+    {
+
+        private final int m_mode;
+        private int requestCount = 0;
+        private Cookie[] m_cookies;
+
+
+        public CookieServlet( int mode )
+        {
+            this.m_mode = mode;
+        }
+
+
+        public Cookie[] getCookies()
+        {
+            return m_cookies;
+        }
+
+
+        protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException
+        {
+            m_cookies = req.getCookies();
+
+            switch ( m_mode )
+            {
+                case MODE_NONE_SET:
+                    Cookie[] cookies = req.getCookies();
+
+                    assertNull( cookies );
+
+                    break;
+                case MODE_SIMPLE:
+                    requestCount++;
+                    if ( requestCount == 1 )
+                    {
+                        assertNull( req.getCookies() );
+                        Cookie c = new Cookie( "testcookie", "testvalue" );
+                        resp.addCookie( c );
+
+                    }
+                    else if ( requestCount > 1 )
+                    {
+                        Cookie[] c = req.getCookies();
+
+                        assertNotNull( c );
+                        assertTrue( c.length == 1 );
+                        assertTrue( c[0].getName().equals( "testcookie" ) );
+                        assertTrue( c[0].getValue().equals( "testvalue" ) );
+                    }
+
+                    break;
+                case MODE_MULTI:
+                    requestCount++;
+                    if ( requestCount == 1 )
+                    {
+                        assertNull( req.getCookies() );
+                        Cookie c = new Cookie( "testcookie", "testvalue" );
+                        resp.addCookie( c );
+                        c = new Cookie( "testcookie2", "testvalue2" );
+                        resp.addCookie( c );
+                    }
+                    else if ( requestCount > 1 )
+                    {
+                        Cookie[] c = req.getCookies();
+
+                        assertNotNull( c );
+                        assertTrue( c.length == 2 );
+                        assertTrue( c[0].getName().equals( "testcookie" ) );
+                        assertTrue( c[0].getValue().equals( "testvalue" ) );
+                        assertTrue( c[1].getName().equals( "testcookie2" ) );
+                        assertTrue( c[1].getValue().equals( "testvalue2" ) );
+                    }
+
+                    break;
+                default:
+                    throw new ServletException( "Invalid test mode." );
+            }
+        }
+    }
+}
