All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bitbucket.gkutiel.in.my.mind.feature.Cookies Maven / Gradle / Ivy

The newest version!
package org.bitbucket.gkutiel.in.my.mind.feature;

import static java.util.concurrent.TimeUnit.DAYS;
import org.bitbucket.gkutiel.in.Feature;
import com.google.gson.Gson;
import io.netty.handler.codec.http.DefaultCookie;

@SuppressWarnings("deprecation")
public interface Cookies extends Jwt, Feature {

	static final Gson gson = new Gson();

	default void delCookie(final String name) {
		final DefaultCookie cookie = new DefaultCookie(name, "");
		cookie.setMaxAge(0);
		res().addCookie(cookie);
	}

	default  void setCookie(final String key, final T val) {
		final DefaultCookie cookie = new DefaultCookie(key, encode(gson.toJson(val)));
		cookie.setMaxAge(DAYS.toSeconds(365));
		res().addCookie(cookie);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy