[SOLVED] session is working?

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
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

session is working?

Post by pelegk2 »

how can i chck if session works
when igo from 1 page to another?
is there a way to get the session id and to check if it realy saves the data u give it
thnaks in advabce
peleg
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

add this to the top of the page

Code: Select all

<?php
<pre>
print_r($_SESSION);
</pre>
?>
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

well i did ass u told me and it gave me an error so i did

Post by pelegk2 »

Code: Select all

<?php
  session_start();
print_r($_SESSION);
?>
and i get :
Array()
how can i make it print all the data?
User avatar
wwwapu
Forum Contributor
Posts: 197
Joined: Wed Apr 07, 2004 11:57 am
Location: Turku, Finland

Post by wwwapu »

It does print all the data. Your $_SESSION is empty. Did you start session on your first page?
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

you have no session vars


are u sure session_start(); is located on every page?
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

yep
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Does the following work for you? (counter should increment every time you refresh)

Code: Select all

<?php
error_reporting(E_ALL);
session_start();
if(empty($_SESSION['count'])){
  $_SESSION['count'] = 0;
}
echo ++$_SESSION['count'];
?>
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

ok works thanks alot
i maybe did something wrong before
Post Reply