{% extends "../../layout.html" %} {% block sectionClasses %}plugins hasBreadCrumb plugins-spincast-cookies {% endblock %} {% block meta_title %}Plugins - Spincast Cookies{% endblock %} {% block meta_description %}Spincast Cookies plugin provides functionalities to read and write cookies.{% endblock %} {% block scripts %} {% endblock %} {% block body %}
This plugin provides functionalities to read and write HTTP cookies. It also provides an implementation for the Cookie interface : CookieDefault.
.cookies() add-on from a Route Handler
to get a cookie :
public void myHandler(AppRequestContext context) {
Cookie myCookie = context.cookies().getCookie("myCookie");
//...
}
.cookies() add-on :
public void myHandler(AppRequestContext context) {
context.cookies().addCookie("myCookie", "someValue");
//...
}
public class SomeService {
private final CookieFactory cookieFactory;
@Inject
public AppService(CookieFactory cookieFactory) {
this.cookieFactory = cookieFactory;
}
protected CookieFactory getCookieFactory() {
return this.cookieFactory;
}
public Cookie someServiceMethod() {
Cookie cookie = getCookieFactory().createCookie("myCookie", "some value");
return cookie;
}
}
If you use the spincast-default artifact and the standard Bootstrapper,
this plugin is already installed by default so you have nothing to do!
If you start from scratch, using the spincast-core artifact, you can use the
plugin by :
1. Adding this Maven artifact to your project:
<dependency>
<groupId>org.spincast</groupId>
<artifactId>spincast-plugins-cookies</artifactId>
<version>{{spincast.spincastCurrrentVersion}}</version>
</dependency>
2. Installing the provided SpincastCookiesPluginModule module to your Guice context.
The class implementing the SpincastPlugin interface is SpincastCookiesPlugin.
cookies()
Route Handlers.
This add-on is already installed by default on the
Request Context type.