Problem with Session Varables

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

Locked
Zelpus
Forum Newbie
Posts: 5
Joined: Sat Feb 28, 2004 4:53 pm

Problem with Session Varables

Post by Zelpus »

<?php
session_start();
$username= $_POST['logname'];
$_SESSION['name'] = $username;
$userpswd= $_POST['logpswd'];
$_SESSION['pswd'] = $userpswd;
?>

When I goto the next page theres nothing in these varables, is there something I need to do to register these that I am not doing?

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

Post by markl999 »

And the second page also has session_start() in it? Eg
session_start();
var_dump($_SESSION);
Zelpus
Forum Newbie
Posts: 5
Joined: Sat Feb 28, 2004 4:53 pm

Post by Zelpus »

I am reloading everything into the same page, so session_start is in every page. I have never seen var_dump what does it do?

Thanks in advanced.
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

This has nothing to do with theory and design.
cyberhawk
Forum Newbie
Posts: 11
Joined: Tue Mar 02, 2004 7:49 pm

The solution... maybe.. :)

Post by cyberhawk »

I had the same problem, check your php.ini and locate this:

session.use_trans_sid = 0

and change the 0 to 1:

session.use_trans_sid = 1

Then reboot your puter.

And then your script will work, promise.

And 4 some code, have a look at my little test.

First page

Code: Select all

<?php 
session_start(); 

$un = "anders"; 

$_SESSION['uname']=$un; 
$_SESSION['ualias']='olle'; 
echo '<pre>'; 
print_r($_SESSION); 
echo '</pre>'; 
?> 

<p><a href="test4.php">Page 2</a></p>

Second page

Code: Select all

<?php 
session_start(); 

echo '<pre>'; 
print_r($_SESSION); 
echo '</pre>'; 

echo $_SESSION['uname']; 
echo $_SESSION['ualias']; 

?>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Please don't cross-post it's totally unneccessary.

Mac
Locked