Permalink
Browse files

Session functions: Implemented some deprecated ones and put in _exper…

…imental, moved some to not nonporting, move test files to test directory
  • Loading branch information...
brettz9 committed Aug 27, 2010
1 parent ff0e9ff commit 4c64dcd9857ac31b7f8b693d2354111ec78a7a77
@@ -0,0 +1,10 @@
+function session_is_registered (name) {
+ // http://kevin.vanzonneveld.net
+ // + original by: Brett Zamir (http://brett-zamir.me)
+ // % note 1: Deprecated in PHP
+ // * example 1: session_is_registered('someUnregisteredGlobalVarName');
+ // * returns 1: false
+
+ var obj = this.$_SESSION ? this : window; // Can be stored on the namespaced object
+ return !!(obj.$_SESSION) && typeof obj.$_SESSION[name] !== 'undefined';
+}
@@ -0,0 +1,24 @@
+function session_register () {
+ // http://kevin.vanzonneveld.net
+ // + original by: Brett Zamir (http://brett-zamir.me)
+ // % note 1: Deprecated in PHP
+ // * example 1: session_register('someVarName');
+ // * returns 1: true
+
+ var name = '', obj = this.$_SESSION ? this : window; // Allow storage on the namespaced object
+
+ if (!this.$_SESSION && !window.$_SESSION) {
+ window.$_SESSION = {};
+ }
+
+ for (var i = 0, argc = arguments.length; i < argc; i++) {
+ if (typeof arguments[i] !== 'string') {
+ this.session_register(arguments[i]); // Probably an array
+ }
+ else {
+ name = arguments[i];
+ obj.$_SESSION[name] = window[name];
+ }
+ }
+ return true;
+}
@@ -0,0 +1,13 @@
+function session_unregister (name) {
+ // http://kevin.vanzonneveld.net
+ // + original by: Brett Zamir (http://brett-zamir.me)
+ // % note 1: Deprecated in PHP
+ // * example 1: session_unregister('someVarName');
+ // * returns 1: true
+
+ var obj = this.$_SESSION ? this : window; // Allow storage on the namespaced object
+ if (obj.$_SESSION) {
+ delete obj.$_SESSION[name];
+ }
+ return true;
+}
@@ -1,3 +0,0 @@
-function session_is_registered () {
-
-}
@@ -1,3 +0,0 @@
-function session_register () {
-
-}
@@ -1,3 +0,0 @@
-function session_unregister () {
-
-}
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -6,7 +6,7 @@
<link rel="stylesheet" href="http://github.com/jquery/qunit/raw/master/qunit/qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="http://github.com/jquery/qunit/raw/master/qunit/qunit.js"></script>
<script type="text/javascript" src="php.default.min.js"></script>
-<script type="text/javascript" src="session_start.js"></script>
+<script type="text/javascript" src="session.js"></script>
<script>

0 comments on commit 4c64dcd

Please sign in to comment.