0
내 vertx 서버가 Java로되어 있고 Js로 세션을 만들고 싶을 때 브라우저에 키가있는 쿠키가 없습니다. 하지만 URL로 직접 세션을 만들면 브라우저에 쿠키가 생깁니다. 내 서버 :vertx 세션 내 브라우저에서 쿠키를 생성하지 마십시오
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx));
router.get("/log/:name/:password").handler(this::verifId);
public void verifId(RoutingContext routingContext) {
HttpServerRequest request = routingContext.request();
HttpServerResponse response = routingContext.response();
try {
Session s = routingContext.session();
DataBase.connect();
String name = request.getParam("name");
String password = request.getParam("password");
Boolean returnValue = DataBase.exist(name, password);
DataBase.disconnect();
if (returnValue) {
s.put("user", request.getParam("name"));
System.out.println(s.id());
response.end(Json.encodePrettily(s.id().toString()));
} else {
s.destroy();
response.end("null");
}
} catch (SQLException e) {
e.printStackTrace();
}
}
그리고 내 JS 코드 :
function tryToLogin(login, password){
var urlBuilder = 'https://localhost:8090/log/' + login + '/' + password;
$.ajax({
url : urlBuilder,
type: 'get',
dataType: 'json',
success : function(code_json, statut){
console.log(" il a repondu " + code_json);
}
});
}