Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Coding Releases > Coding Snippets
You last visited: Today at 23:03

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[PHP] Easy Cookie/Session functions

Discussion on [PHP] Easy Cookie/Session functions within the Coding Snippets forum part of the Coding Releases category.

Reply
 
Old   #1



 
Shawak's Avatar
 
elite*gold: 0
The Black Market: 259/0/0
Join Date: Apr 2010
Posts: 10,289
Received Thanks: 3,613
[PHP] Easy Cookie/Session functions

It should be explain itself.

Code:
<?php
	/*
		set session:
		SESSION(<name>, <value>);
		
		get session:
		$value = SESSION(<name>);
		
		delete session:
		$value = SESSION(<name>, null);
	*/
	function SESSION($session, $value = '') {
		if($value === '') {
			if(isset($_SESSION[$session]))
				return $_SESSION[$session];
		} else if($value !== null)
			$_SESSION[$session] = $value;
		else
			$_SESSION[$session] = null;
	}

	/*
		set cookie:
		COOKIE(<name>, <value>[, <expire[seconds]>]);
		(Expire Default: Until January 2018)
		
		get cookie:
		$cookie = COOKIE(<name>);
	
		del cookie:
		COOKIE(<name>, null);
	*/
	function COOKIE($cookie, $value = '', $expire = null) {
		if($value === '') {
			if(isset($_COOKIE[$cookie]))
				return $_COOKIE[$cookie];
		} else {
			if($value === null)
				$expire = -3600;
			else if($expire === null)
				$expire = 2147483647; // 2^31 - 1
			setcookie($cookie, $value, time() + $expire);
		}
	}
?>
Lg
Shawak is offline  
Reply




All times are GMT +1. The time now is 23:05.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.