Jump to content

session, coockie ! :(((


asmith

Recommended Posts

this book is now trying sessions , i've tried this :

 

<?php

session_start();

session_register('count');

$_session[count]++;

 

$msg="you've been here $_session[count] times";

?>

<html>

<head>

<title>start a session count</title>

</head>

<body>

<?php

echo $msg;

?>

</body>

</html>

 

 

when i load this page i only see,  you've been here 1 times,

by refreshing the page that number won't add up ! as the book says !

pleeease help !!

the only change i made for sessions was i did a little change in php.ini , session.save_path = c:/temp , now i can see some file in this directory with session type id ,  (have restart apache too)

but why neither cookie nor sessions are working ?? :((((((

Link to comment
https://forums.phpfreaks.com/topic/77842-session-coockie/
Share on other sites

Try this instead

 

<?php
session_start();

if (isset($_SESSION['count']))
   $_SESSION['count']++;
else
   $_SESSION['count'] = 1;


$msg="you've been here {$_SESSION['count']} times";
?>
<html>
<head>
<title>start a session count</title>
</head>
<body>
<?php
echo $msg;
?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/77842-session-coockie/#findComment-393992
Share on other sites

I notice you typed your session var as $_session['count'] PHP is case sensitive with variable names. $_session or $_SESSION or even $_SeSsIoN are three completely different variables.

 

When ever using any  superglobal variables (_POST, _GET, _SESSION, _COOKIE etc) always type in caps.

Link to comment
https://forums.phpfreaks.com/topic/77842-session-coockie/#findComment-393996
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.