Jump to content

Session not working?


ash992

Recommended Posts

Hey guys, Before I say my problem I'de just like to say that I'm new to PHP So there's a good chance it's a simple mistake.

 

On my index there's a form with a text input that takes someones organisations name, there's also a select in the same form, this form redirects to a PHP file that decides what page you will be redirected to, depending on what you chose in the select box, The organisation name is set on the main page through the text input, and the session is set on the form's action, but when it re-directs to the new header the session is not working.

 

$Companyname = $_POST['Companyname'];
$_SESSION['CNAME'] = $_POST['Companyname'];

That's the pieces of code that should set it, after that it redirects to the header sucsessfully, but when i try to echo the session variable, or even add it to a normal variable to echo it, It doesn't work.

 

Additional information includes, I have started the session on the Index, and again on the form's action file, and again on the header of that file, so the session is started on all of them.

 

Anyone got any Ideas? I really don't know what's wrong with it really.. Thank's in advanced everyone.

Link to comment
https://forums.phpfreaks.com/topic/265272-session-not-working/
Share on other sites

They do indeed, and the code on the file it redirects to is here

<?php
session_start(); 
$_SESSION['CNAME'] = $cpnamerrr;
echo $cpnamerrr;
?>

 

And I'm not getting any output? it also doesn't work if I just try to echo the

$_SESSION['CNAME']

straight away, The reason I'm turning it into a normal variable instead of a Session by the way is because I use it later on in a form for it's value,

 

Thanks again.

Link to comment
https://forums.phpfreaks.com/topic/265272-session-not-working/#findComment-1359432
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.