Page 1 of 1

sessions help, PLEASE!!!!

Posted: Fri Jan 16, 2004 4:22 pm
by lizlazloz
heres my code:

Code: Select all

<?php
session_start();
header("Cache-control: private");

if(!$_SESSION['count'])
{
if ( getenv("REMOTE_ADDR") != $row[ip_address] )
{
$_SESSION['count'] = 1;
//do all the stuff
}
}
?>
ok, so it should check to see if this session has been made before, then if not (and the ip is correct) 'do all the stuff'.

the problem is, it always 'does all the stuff', the session never gets assigned a value or soemthing... please help...

Posted: Fri Jan 16, 2004 4:45 pm
by Gen-ik
Try if(!isset($_SESSION["count"]))

Posted: Fri Jan 16, 2004 8:50 pm
by patrikG
also, see if $_SERVER["REMOTE_ADDR"] instead of getenv("REMOTE_ADDR") helps.

Edit: corrected typo

Posted: Sat Jan 17, 2004 7:31 am
by Abdel
if all this doesn't work, check if session id "SID" is sent automatically for this you can check if sess_auto_trans_sissid in your php.ini file(it should look like) if it is is on, if not you must send the session id from one page to another using URL rewriting, like this for example
for links: <a href="yourpage.php?<?php echo SID;?>">go to that
page</a>
for forms: <form action="yourpage.php?<?php echo SID;?>" method="POST">
for redirection: header('Location: yourpage.php?'.SID);