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
Share on other sites

Yep, If i remove the header so it stays on that page, and try to echo

$_SESSION['CNAME']

Then it works fine, but if i try to echo it on the file that it re-directs to then there is no output. :s

 

Thank-you for the help and the fast reply,

Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.