Session id transfered, but not variables

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Mongrel
Guest





PostPosted: Sun Feb 02, 2003 8:07 pm    Post subject: Session id transfered, but not variables Reply with quote

I'm having problems with session variables.

I define them first thing in document 1:

<?php ob_start();session_unset();session_start();
$path_plugins = "plugins/";
session_register("path_plugins");

The variables work fine in document 1. When entering document 2, though, something goes wrong. The session file is created, and i put this code in at the top of document 2 to see what was going on:

echo( "session_id: ".session_id() ."<br>");
echo( "session_encode: ".session_encode()."<br>");
echo( "db_host: ".$db_host."<br>");

The output:

session_id: b2b0f37b1f2604d41ef032c920195c4c
session_encode: path_plugins|N;
db_host:

As you can see, the session id and session content look fine. Still, my variable is empty.

Does anyone know if I'm doing something wrong, or if I need to change my configuration? I've been searching the manuals and the Internet for hours without any result.
Back to top
Guest






PostPosted: Sun Feb 02, 2003 8:15 pm    Post subject: Reply with quote

>session_id: b2b0f37b1f2604d41ef032c920195c4c
>session_encode: path_plugins|N;
>db_host:
>
>As you can see, the session id and session content look fine. Still, my
>variable is empty.

Erm, no, sorry. The session content doesn't look fine, just the id.[/quote]
Back to top
Mongrel
Guest





PostPosted: Sun Feb 02, 2003 11:01 pm    Post subject: Session id transfered, but not variables Reply with quote

Whoa!

Finally, a solution!

File 1:

<?php session_start();
$path_plugins = "plugins/";
session_register("path_plugins");

File 2:

$path_plugins = $_SESSION['path_plugins'];
global $path_plugins;
echo( "path_plugins: ".$path_plugins."<br><br>");

Returns:

path_plugins: plugins/


Thanks rboos at Zend.com (http://zend.com/zend/comments/show_comment.php?article=session&id=1875&pid=1742&days=10000&f_id=session&mode=&kind=at)
Back to top
Omar G
Guest





PostPosted: Tue Feb 04, 2003 9:54 am    Post subject: Use $)SESSION["foo"] Instead Reply with quote

Use $)SESSION["foo"] Instead; it is a superglobal and would prevent you from having to use session_register as well as the semi-depreciated global "foo"...It will save you plenty of heart-ache in the future.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group