You are here: $_SESSION problems « All PHP « IT news, forums, messages
$_SESSION problems

Posted by flintridgeparkenfarker vonkerschnauzerheiden on 07/24/05 10:58

I'm new to PHP and although it seems like a powerful construct, I'm getting
very frustrated dealing with sessions. My results seem inconsistent.

I'm simply trying to access the $_SESSION[] variables when I return to the
page with the following code in it but they are always empty--I've tried
moving/removing session_start() but nothing seems to work--the variables are
empty when I return to this page:

<?
session_name('cookiesetter');
session_start();

if (!isset($_COOKIE['testcookie'])) {
if (!setcookie('testcookie', SID)) {
echo "could not set cookie...exiting...";
exit();
}
else {
echo "session_id(): " . session_id() . "<BR />";
echo "SID: " . SID . "<BR />";
$_SESSION['sessid']=session_id(); // just the number
$_SESSION['cookieval']=SID; // session name and number
$_SESSION['sessname']=session_name();

echo "sessid = " . $_SESSION['sessid'] . "<BR />";
echo "cookieval = " . $_SESSION['cookieval'] . "<BR />";
echo "sessname = " . $_SESSION['sessname'] . "<BR />";
}
}
else {
//session_start();
$sessinfo = session_name() . "=" . session_id();
echo "sessinfo = " . $sessinfo . "<BR />";

echo "COOKIE: " . $_COOKIE['testcookie'] . "<BR />";
echo "SID: " . SID . "<BR />"; //SID empty because valid cookie was
retrieved(?) by client
echo "SESSION[sessid] = " . $_SESSION['sessid'] . "<BR />";
echo "SESSION[cookieval] = " . $_COOKIE['cookieval'] . "<BR />";
echo "SESSION[name] = " . $_SESSION['sessname'];
}

?>


Would someone clue me in please? Thanks...

joe

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация