session.java
来自「jdbc书」· Java 代码 · 共 44 行
JAVA
44 行
package login;
import java.util.Random;
import java.net.*;
public class Session {
private String theuser;
private int id;
private long expires;
public Session (String theuser) {
this.theuser = URLEncoder.encode (theuser);
id = Math.abs(new Random (System.currentTimeMillis()).nextInt());
expires = 0;
}
synchronized public void setExpires (long e) {
expires = e;
}
public long getExpires() {
return expires;
}
public String key() {
return String.valueOf (id);
}
public String getEncodedUser() {
return theuser;
}
public String getUser() {
try {
return URLDecoder.decode (theuser);
}catch (Exception e) {
return null;
}
}
public int getId() {
return id;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?