Jump to content

session vars


pacome

Recommended Posts

I'm trying to pass some variables through a session with PHP 4.329 but I can't manage to get them through the pages...

My host's has this info

Session Support  enabled 
Registered save handlers  files user 

Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /var/lib/php/session /var/lib/php/session
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid Off Off

and my script is page 1:

<?php
session_start();
session_name('ses');
if ($_POST[nicksess])
{
$nicksess=$_POST['nicksess'];
//$nicksess=$_POST[nicksess];
//session_register("nicksess");
echo "<html><body><a href='page2.php'>go to page 2</a><br>".$_POST['nicksess']." <br>y ".$nicksess."</body></html>";
}
else {

?>
<html><head></head>
<body>
<form action='page1.php' method='POST'>
<input type='text' name='nicksess'>Name<br>
<input type='password' name='pass'><br>
<input type='submit' name='submit' value='submit'></form>
</body></html>
<?php
}
?>


and page 2 is:

<?php
session_start();
session_name('ses');
echo "<html><body>Mi nick es:".$_SESSION["nicksess"]." </body></html>";

?>

When I put my name I print correctly $_SESSION["nicksess"] and $nicksess, but when I click to page 2 the nick doesn't print! :(

any ideas?

thanks!
Link to comment
Share on other sites

You don't store the variable in the $_SESSION array in your first script, so you can't get it in your second script.

Change:
[code]<?php
if ($_POST[nicksess])
{
$nicksess=$_POST['nicksess'];
?>[/code]

to
[code]<?php
if ($_POST[nicksess])
{
$nicksess=$_POST['nicksess'];
$_SESSION['nicksess'] = $_POST['nicksess'];
?>[/code]

Ken
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.