Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

identify session with session.use_trans_sid set to 0

Status
Not open for further replies.

plarsen

Programmer
Jul 30, 2002
27
DK
Hi

My new host has session.use_trans_sid set to 0 (Off) and I have place in my code that says

Code:
<?
global $asess_name, $asess_passwd, $asess_data;
session_register("asess_name");
session_register("asess_passwd");
session_register("asess_data");
global $login, $passwd;
$asess_name = $login;
$asess_passwd = $passwd;
header("Location: ?".SID);
?>

The variables $login and $passwd comes from form fields.

Then the page is redirected I use the following to see if there is a session available.

Code:
if (!isset($HTTP_SESSION_VARS["asess_name"])) {

How do I get this to work again on my new host?

Thanks

Peter Larsen
 
What version of PHP is your host running? If it's newer than 4.1.0, you should be using the so-called "short" PHP predefined variable names ($_POST, $_GET, $_SESSION) rather than the so-called "long" ones ($HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_SESSION_VARS). The "short" variables are superglobal and as such are available in all variable scopes.

Also, the PHP online manual for session_register() (link) states, "If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled."

Unless your hosting provider has in php.ini the runtime configuration setting session.auto_start set to "1" or "on", you're going to need to invoke session_start() in every script that uses sessions.

I also don't understand what you mean for the "global" keyword to do in the context in which you are using it.

But one version of your code could read (assuming that the forms are begin submitted via POST):

Code:
<?php
session_start();
$_SESSION['asess_name'] = $_POST['login'];
$_SESSION['asess_passwd'] = $_POST['passwd'];
header("Location: ?".SID);
?>

Code:
.
.
.
if (!isset($_SESSION['asess_name'])) {
.
.
.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Hi sleipnir214

Thank you for your reply, I changed the $HTTP_SESSION_VARS to $_SESSION and it worked fine again.

Thank you so much.

Cheers,

Peter L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top