मैं आपको सलाह देता हूं कि आप play-1.x/मॉड्यूल/सुरक्षित और फ़ाइल Secure.java में प्रदान किए गए सुरक्षित मॉड्यूल पर नज़र डालें ... यह लॉगिन फ़ॉर्म में "मुझे याद रखें" चेकबॉक्स प्रदान करता है आपको अनंत काल के लिए लॉग इन रखने की अनुमति देता है।
और इस समारोह (विशेष रूप से अंत में response.setCookie) का कोड:
public static void authenticate(@Required String username, String password, boolean remember) throws Throwable {
// Check tokens
Boolean allowed = false;
try {
// This is the deprecated method name
allowed = (Boolean)Security.invoke("authentify", username, password);
} catch (UnsupportedOperationException e) {
// This is the official method name
allowed = (Boolean)Security.invoke("authenticate", username, password);
}
if(validation.hasErrors() || !allowed) {
flash.keep("url");
flash.error("secure.error");
params.flash();
login();
}
// Mark user as connected
session.put("username", username);
// Remember if needed
if(remember) {
response.setCookie("rememberme", Crypto.sign(username) + "-" + username, "30d");
}
// Redirect to the original URL (or /)
redirectToOriginalURL();
}
पास्कल
कृपया उस प्रश्न को बंद करने के लिए उत्तर दें। यह दूसरों की भी मदद करेगा। धन्यवाद :) –