Jump to content

echo $_SESSION Works on Localhost but not on Server...


suttercain

Recommended Posts

Hi Guys,

 

I have a simple form the end user fills out. After validation they are taken to the preview page. If the information is incorrect they can hit the edit button which will take them back to the form.

 

When I hit edit and am taken back to the form on my localhost all the information is echoed back into the form using sessions and works as desired:

 

<input name="street" id="street" class="required" title="Enter your last address" value="<?php echo $_SESSION['street']; ?>"/>

 

Now when I upload the same files and try them on the server, hit edit and am taken back to the form, all the fields are blank and the user must re enter all the information starting from scratch.

 

I check the phpfile info for both the localhost and the server and here is what I got:

 

LOCALHOST PHPINFO()

PHP Version 5.2.0

Session Support enabled

Registered save handlers files user sqlite

Registered serializer handlers php php_binary wddx

session.auto_start Off Off

session.bug_compat_42 On On

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_httponly Off Off

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 100 100

session.gc_maxlifetime 1440 1440

session.gc_probability 1 1

session.hash_bits_per_character 4 4

session.hash_function 0 0

session.name PHPSESSID PHPSESSID

session.referer_check no value no value

session.save_handler files files

session.save_path c:/wamp/tmp c:/wamp/tmp

session.serialize_handler php php

session.use_cookies On On

session.use_only_cookies Off Off

session.use_trans_sid 0 0

 

SERVER PHPINFO()

PHP Version 5.1.2

Session Support enabled

Registered save handlers files user sqlite

Registered serializer handlers php php_binary

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.hash_bits_per_character 5 5

session.hash_function 0 0

session.name PHPSESSID PHPSESSID

session.referer_check no value no value

session.save_handler files files

session.save_path no value no value

session.serialize_handler php php

session.use_cookies On On

session.use_only_cookies Off Off

session.use_trans_sid 0 0

 

Also I am using

<?php session_start(); ?>

at the top of both pages before the headers are being sent.

 

Does anyone know why the LOCALHOST is ecohing the sessions back into the forms but the SERVER isn't?

 

Thanks for any help or suggestions.

 

SC

Link to comment
Share on other sites

What's your form action="?"  Have you tested sessions otherwise on this server to make sure they work properly?

 

 

(As a general idea, what I often do at the bottom of a page I'm debugging is this:

<?php
$Debugging = TRUE;

if ($Debugging) {
if (isset($_SESSION)) {
	echo "<font face=Arial size=+1>\$_SESSION</font><br><hr width=50% noshade size=1 align=left>\n";
	echo "<pre>\n";
	foreach ($_SESSION as $key => $value) {
		echo "$key = ";
		print_r($value);
		echo "\n";
	}
	echo "</pre>\n";
}

if (isset($GLOBALS)) {
	echo "<font face=Arial size=+1>\$GLOBALS</font><br><hr width=50% noshade size=1 align=left>\n";
	echo "<pre>\n";
	foreach ($GLOBALS as $key => $value) {
		echo "$key = ";
		print_r($value);
		echo "\n";
	}
	echo "</pre>\n";
}
}
?>

 

It helps me see what's getting passed in detail.)

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.