cookies rewritten to session
[mailer.git] / inc / session.php
index 49d7c986255fde34b279fb48507d0d7072aa0afc..268c2d4715fe818e0a2669a7c54652dc2ba04d3d 100644 (file)
@@ -46,22 +46,12 @@ if (empty($VIEW))  $VIEW  = 0;
 // Skip updating of cookies when viewing a banner
 if (($VIEW == 1) && ($_SERVER['PHP_SELF'])) return;
 
-// Session management initalization
-if (empty($PHPSESSID)) {
-       // This fixes some strange session cookie problems
-       if (empty($_COOKIE['PHPSESSID'])) unset($_COOKIE['PHPSESSID']);
-       @session_start();
-       $PHPSESSID = @session_id();
-} else {
-       @session_id($PHPSESSID);
-       @session_start();
-}
-
-// Store PHPSESSID
-@setcookie("PHPSESSID", $PHPSESSID, (time() + $_CONFIG['online_timeout']), COOKIE_PATH);
+// Start the session
+@session_start();
+$PHPSESSID = @session_id();
 
 // Store language code in cookie
-@setcookie("mx_lang", $mx_lang, (time() + $_CONFIG['online_timeout']), COOKIE_PATH);
+set_session("mx_lang", $mx_lang);
 
 // Check if refid is set
 if ((!empty($_GET['user'])) && ($CLICK == 1) && ($_SERVER['PHP_SELF'] == "click.php")) {
@@ -78,9 +68,9 @@ if (!empty($_POST['refid'])) {
 } elseif (!empty($_GET['ref'])) {
        // Set refid=ref (the referral link uses such variable)
        $GLOBALS['refid'] = SQL_ESCAPE(strip_tags($_GET['ref']));
-} elseif (!empty($_COOKIE['refid'])) {
+} elseif (!empty($_SESSION['refid'])) {
        // Simply reset cookie
-       $GLOBALS['refid'] = bigintval($_COOKIE['refid']);
+       $GLOBALS['refid'] = bigintval($_SESSION['refid']);
 } elseif (GET_EXT_VERSION("sql_patches") != "") {
        // Set default refid as refid in URL
        $GLOBALS['refid'] = $_CONFIG['def_refid'];
@@ -90,15 +80,15 @@ if (!empty($_POST['refid'])) {
 }
 
 // Set cookie when default refid > 0
-if (empty($_COOKIE['refid']) || (!empty($GLOBALS['refid'])) || (($_COOKIE['refid'] == "0") && ($_CONFIG['def_refid'] > 0))) {
+if (empty($_SESSION['refid']) || (!empty($GLOBALS['refid'])) || (($_SESSION['refid'] == "0") && ($_CONFIG['def_refid'] > 0))) {
        // Set cookie
-       @setcookie("refid", $GLOBALS['refid'], (time() + $_CONFIG['online_timeout']), COOKIE_PATH);
+       set_session("refid", $GLOBALS['refid']);
 }
 
 // Test cookies if index.php or modules.php is loaded
 if ((basename($_SERVER['PHP_SELF']) == "index.php") || (basename($_SERVER['PHP_SELF']) == "modules.php") || (mxchange_installing))
 {
-       if (count($_COOKIE) > 0)
+       if (count($_SESSION) > 0)
        {
                // Cookies accepted!
                define('__COOKIES', true);