summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/wordpress-mobile-pack/inc/class-wmp-cookie.php')
-rw-r--r--plugins/wordpress-mobile-pack/inc/class-wmp-cookie.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/wordpress-mobile-pack/inc/class-wmp-cookie.php b/plugins/wordpress-mobile-pack/inc/class-wmp-cookie.php
new file mode 100644
index 00000000..37773842
--- /dev/null
+++ b/plugins/wordpress-mobile-pack/inc/class-wmp-cookie.php
@@ -0,0 +1,54 @@
+<?php
+
+if ( ! class_exists( 'WMobilePack_Cookie' ) ) {
+
+ /**
+ * Overall Cookie Management class
+ *
+ * Instantiates all the cookies and offers a number of utility methods to work with the cookies
+ */
+ class WMobilePack_Cookie
+ {
+
+ /* ----------------------------------*/
+ /* Properties */
+ /* ----------------------------------*/
+
+ public static $prefix = 'wmp_';
+
+ /* ----------------------------------*/
+ /* Methods */
+ /* ----------------------------------*/
+
+ /**
+ *
+ * Get cookie value
+ *
+ * @param $cookie_name
+ * @return null
+ *
+ */
+ public function get_cookie($cookie_name)
+ {
+
+ if (isset($_COOKIE[self::$prefix.$cookie_name])){
+ return $_COOKIE[self::$prefix.$cookie_name];
+ }
+
+ return null;
+ }
+
+ /**
+ * Set cookie value
+ *
+ * @param $cookie_name
+ * @param $cookie_value
+ * @param $duration - After how many seconds the cookie will expire. Default value is 2 days
+ */
+ public function set_cookie($cookie_name, $cookie_value, $duration = 172800)
+ {
+ setcookie(self::$prefix.$cookie_name, $cookie_value, time()+$duration,'/');
+ }
+
+ }
+} \ No newline at end of file