1
josecruz
cookies and sessions
  • 2004/7/15 9:19

  • josecruz

  • Just popping in

  • Posts: 68

  • Since: 2003/3/28


Hi everyone,

I need a solution to getting a japanese cellular phone to work completely with XOOPS when the phones here will not accept cookies. I've asked around and have been told that it could be as simple as changing prefs in php.ini. Or perhaps it might involve a hack with php_session.

I would very much appreciate information on the topic, and paying for the solution is not out of the question.

Jose

2
Mithrandir
Re: cookies and sessions

I looked into this a little and found that it should work by default if the user is not accepting cookies, simply by adding the PHPSESSID to the url, except with redirects, where I found this in the PHP Cookbook:
if (defined('SID') && (! isset($_COOKIE[session_name()]))) {
     
$redirect_url .= '?' SID;
}


Would getting XOOPS to work without cookies simply involve changing the redirect_header() function to include something similar to this? A clause to find out if the user is accepting cookies and if not, adding it to the redirect URL?

3
josecruz
Re: cookies and sessions
  • 2004/7/21 23:57

  • josecruz

  • Just popping in

  • Posts: 68

  • Since: 2003/3/28


Thanks for the answer Mithrandir,

Sorry it took so long to get back to you. What exactly would your first suggestion of
Quote:
adding the PHPSESSID to the url,

involve as a hack? What file would I be hacking? Please contact me privately if you feel that would be more efficient.

Jose

4
Mithrandir
Re: cookies and sessions

Try replacing redirect_header() in include/functions.php with this one:
function redirect_header($url$time 3$message ''$addredirect true)
{
    global 
$xoopsConfig$xoopsRequestUri;
    if (!
defined('XOOPS_CPFUNC_LOADED')) {
        require_once 
XOOPS_ROOT_PATH.'/class/template.php';
        
$xoopsTpl = new XoopsTpl();
        
$xoopsTpl->assign('sitename'$xoopsConfig['sitename']);
        
$xoopsTpl->assign('langcode'_LANGCODE);
        
$xoopsTpl->assign('charset'_CHARSET);
        
$xoopsTpl->assign('time'$time);
        if (
$addredirect && strstr($url'user.php')) {
            if (!
strstr($url'?')) {
                
$url .= '?xoops_redirect='.urlencode($xoopsRequestUri);
            } else {
                
$url .= '&xoops_redirect='.urlencode($xoopsRequestUri);
            }
        }
        if (
defined('SID') && (! isset($_COOKIE[session_name()]) || ($xoopsConfig['use_mysession'] && $xoopsConfig['session_name'] != '' && !isset($_COOKIE[$xoopsConfig['session_name']])))) {
            if (!
strstr($url'?')) {
                
$url .= '?' SID;                
            }
            else {
                
$url .= '&'.SID;
            }
        }
        
$url preg_replace("/&/i"'&'htmlspecialchars($urlENT_QUOTES));
        
$xoopsTpl->assign('url'$url);
        
$message trim($message) != '' $message _TAKINGBACK;
        
$xoopsTpl->assign('message'$message);
        
$xoopsTpl->assign('lang_ifnotreload'sprintf(_IFNOTRELOAD$url));
        
$GLOBALS['xoopsModuleUpdate'] = 1;
        
$xoopsTpl->display('db:system_redirect.html');
        exit();
    } else {
        
$url preg_replace("/&/i"'&'htmlspecialchars($urlENT_QUOTES));
        echo 
'
        <html>
        <head>
        <title>'
.$xoopsConfig['sitename'].'</title>
        <meta http-equiv="Content-Type" content="text/html; charset='
._CHARSET.'" />
        <meta http-equiv="Refresh" content="'
.$time.'; url='.$url.'" />
        <style type="text/css">
                body {background-color : #fcfcfc; font-size: 12px; font-family: Trebuchet MS,Verdana, Arial, Helvetica, sans-serif; margin: 0px;}
                .redirect {width: 70%; margin: 110px; text-align: center; padding: 15px; border: #e0e0e0 1px solid; color: #666666; background-color: #f6f6f6;}
                .redirect a:link {color: #666666; text-decoration: none; font-weight: bold;}
                .redirect a:visited {color: #666666; text-decoration: none; font-weight: bold;}
                .redirect a:hover {color: #999999; text-decoration: underline; font-weight: bold;}
        </style>
        </head>
        <body>
        <div align="center">
        <div class="redirect">
          <span style="font-size: 16px; font-weight: bold;">'
.$message.'</span>
          <hr style="height: 3px; border: 3px #E18A00 solid; width: 95%;" />
          <p>'
.sprintf(_IFNOTRELOAD$url).'</p>
        </div>
        </div>
        </body>
        </html>'
;
    }
    exit();
}

5
Mithrandir
Re: cookies and sessions

Just tried my own suggestion as well as blocking cookies from my test site.

I can login and it works, but whenever I click a link, I am logged out again as the session ID is not added to links automatically, which I thought it would be if cookies were disabled. The redirect function works, though...

Login

Who's Online

201 user(s) are online (140 user(s) are browsing Support Forums)


Members: 0


Guests: 201


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits