Session issues
Posted: Fri May 28, 2010 1:33 am
Hi,
I'm new with sessions and would need some help - if somebody can point me out to the solution, i'd be more than happy.
Well, here is the issue.
I have two files:
number1.php
print_r outputs an array - so far, so good.
number2.php
Now, it looks like $_SESSION is empty.
Also i get "Warning: session_start() [function.session-start]: Cannot send session cookie..." error, eventhough i put php code before html tag. If i put the @ sign before session_start, i don't get warnings but i'm not sure if this is right thing to do.
What I'm i doing wrong?
I'm new with sessions and would need some help - if somebody can point me out to the solution, i'd be more than happy.
Well, here is the issue.
I have two files:
number1.php
Code: Select all
<?php
// starting the session
session_start();
// setting up variable in the session
$_SESSION['variable']="data";
print_r($_SESSION);
?> number2.php
Code: Select all
<?php
// starting the session again
session_start();
// echo variable from the session that i set up on number1.php
echo 'My variable is ' . $_SESSION['variable'];
print_r($_SESSION);
?> Also i get "Warning: session_start() [function.session-start]: Cannot send session cookie..." error, eventhough i put php code before html tag. If i put the @ sign before session_start, i don't get warnings but i'm not sure if this is right thing to do.
What I'm i doing wrong?