sessions help, PLEASE!!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lizlazloz
Forum Commoner
Posts: 64
Joined: Mon Dec 29, 2003 7:29 am

sessions help, PLEASE!!!!

Post 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...
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Try if(!isset($_SESSION["count"]))
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

also, see if $_SERVER["REMOTE_ADDR"] instead of getenv("REMOTE_ADDR") helps.

Edit: corrected typo
Last edited by patrikG on Sat Jan 17, 2004 8:33 am, edited 1 time in total.
Abdel
Forum Newbie
Posts: 2
Joined: Sat Jan 17, 2004 7:31 am

Post 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);
Post Reply