summaryrefslogtreecommitdiff
path: root/inc/user.php
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@n0v4.com>2010-11-02 21:57:33 +1100
committerSavetheinternet <savetheinternet@n0v4.com>2010-11-02 21:57:33 +1100
commit3d92990b1817ac20935274682764711080e8b254 (patch)
tree4eb12e4952e1a3c7f8454edad37056ed09c41def /inc/user.php
first commit
Diffstat (limited to 'inc/user.php')
-rw-r--r--inc/user.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/inc/user.php b/inc/user.php
new file mode 100644
index 00000000..1dad35f9
--- /dev/null
+++ b/inc/user.php
@@ -0,0 +1,16 @@
+<?php
+
+ session_name(SESS_COOKIE);
+ session_start();
+
+ if(!isset($_SESSION['created'])) $_SESSION['created'] = time();
+
+ if(!isset($_COOKIE[HASH_COOKIE]) || !isset($_COOKIE[TIME_COOKIE]) || $_COOKIE[HASH_COOKIE] != md5($_COOKIE[TIME_COOKIE].SALT)) {
+ $time = time();
+ setcookie(TIME_COOKIE, $time, time()+COOKIE_EXPIRE, '/', null, false, true);
+ setcookie(HASH_COOKIE, md5(time().SALT), time()+COOKIE_EXPIRE, '/', null, false, true);
+ $user = Array('valid' => false, 'appeared' => $time);
+ } else {
+ $user = Array('valid' => true, 'appeared' => $_COOKIE[TIME_COOKIE]);
+ }
+?> \ No newline at end of file