asmith Posted November 18, 2007 Share Posted November 18, 2007 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 ?? ((((( Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 18, 2007 Share Posted November 18, 2007 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> Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted November 18, 2007 Share Posted November 18, 2007 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. Quote Link to comment Share on other sites More sharing options...
asmith Posted November 18, 2007 Author Share Posted November 18, 2007 hey your code worked ! 1.what was wrong with mine?? 2.you know what wrong is with my cookie ???? is has a thread here too\ named $_COOKIE[!] thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.