• R/O
  • SSH
  • HTTPS

webserver: Commit


Commit MetaInfo

Revision63 (tree)
Time2010-11-21 20:05:38
Authorhoritaku

Log Message

クッキー関連

Change Summary

Incremental Difference

--- branch/Basic 0.2x/src/servercore/data/Cookie.java (revision 0)
+++ branch/Basic 0.2x/src/servercore/data/Cookie.java (revision 63)
@@ -0,0 +1,25 @@
1+package servercore.data;
2+
3+public class Cookie {
4+ private long expire = 0;
5+ private String key = null;
6+ private String value = null;
7+ public void setExpire(long expire) {
8+ this.expire = expire;
9+ }
10+ public long getExpire() {
11+ return expire;
12+ }
13+ public void setKey(String key) {
14+ this.key = key;
15+ }
16+ public String getKey() {
17+ return key;
18+ }
19+ public void setValue(String value) {
20+ this.value = value;
21+ }
22+ public String getValue() {
23+ return value;
24+ }
25+}
--- branch/Basic 0.2x/src/servercore/job/SessionCheck.java (revision 0)
+++ branch/Basic 0.2x/src/servercore/job/SessionCheck.java (revision 63)
@@ -0,0 +1,27 @@
1+package servercore.job;
2+
3+import java.util.HashMap;
4+
5+import servercore.data.Cookie;
6+
7+public class SessionCheck {
8+ static private HashMap<String, Cookie> map = new HashMap<String, Cookie>();
9+ static public Cookie getCookie(String key) {
10+ Cookie cookie = map.get(key);
11+ if(cookie == null) {
12+ return null;
13+ }
14+ if(cookie.getExpire() < System.currentTimeMillis()) {
15+ map.put(key, null);
16+ return null;
17+ }
18+ return cookie;
19+ }
20+ static public void setCookie(String key, String value, long expireTo) {
21+ Cookie cookie = new Cookie();
22+ cookie.setKey(key);
23+ cookie.setValue(value);
24+ cookie.setExpire(System.currentTimeMillis() + expireTo * 1000);
25+ map.put(key, cookie);
26+ }
27+}
Show on old repository browser