testing php session

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
peewster
New php-forum User
New php-forum User
Posts: 11
Joined: Mon Oct 10, 2011 3:20 am

Mon Nov 21, 2011 10:37 am

Hi all,

i'm working on a login script and therefore i needed to test something.

The thing is, what i like to test, doesn't seem to do what i want.

example:

Code: Select all

<?PHP
session_start();

$_session['count'] += 1; //doesn't work
//$_session['count'] = $_session['count'] + 1; //this doesn't work either 

echo "This is the ". $_session['count']. " time you've seen this page";
echo "<br>";
echo "This is session: ".session_id()."<br />\n";
?>
The count stays on 1, but the session id keeps the same as it should. I expected the count going up when refreshing...

What am i doing wrong here ?

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Mon Nov 21, 2011 12:18 pm

Well, this may come of a shock to you..
but variables are CASE SenSiTiVe. :)

$_SESSION is not the same as $_session

peewster
New php-forum User
New php-forum User
Posts: 11
Joined: Mon Oct 10, 2011 3:20 am

Tue Nov 29, 2011 1:34 am

egami wrote:Well, this may come of a shock to you..
but variables are CASE SenSiTiVe. :)

$_SESSION is not the same as $_session
lol, i just thought it was session with only non caps, but i got it all working :)

Post Reply