Hi guys.

i am having problem regarding of passing session data from one page to another. In start.php i have this session initialization & assignment.

session_start();

$_SESSION['course']=$_POST['course'];

where the method of the form that this course menu has is set to POST and the action is set to login.php.

At login.php, when i echo the session data that was passed it is null. Why.?

I did it like this:

session_start();
$coursesel=$_SESSION['course'];
echo $coursesel;

Echo returns null but when i echo the $_SESSION in start.php it shows the data assigned to it.

Pls help guys.

Tnx for giving time.

God bless.!

Recommended Answers

All 3 Replies

At login.php, when i echo the session data that was passed it is null. Why.?

Do you have cookies enabled? Also does $_POST exist? And is $_POST a radio button? You need cookies enabled for sessions to work and as for radio buttons, sometimes they will return null if no option is selected or not used properly. I would suggest checking if $_POST has the same value as $_SESSION.

Member Avatar for nileshgr

in start.php, do var_dump($_POST). paste the output here.

thank you for the suggestion..Ive switch to form variables..

Instead of using sessions, i use this method:

$coursesel=$_POST['course'];

In second page. This works. Thank you..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.