Re: Quick session question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Danny wrote:
> Hi guys,
> 
> I always start new projects with the following session code-snippet:
> (In other words this is how I initialize my sessions in the index.php file.)
> 
> ### START CODE SNIPPET ########################################################
> <?php
> 	session_start();
> 	setcookie(session_name(),"",0,"/");
> 	unset($_COOKIE[session_name()]);
> 	$_SESSION = array();
> 	session_unset();
> 	session_destroy();
> 
> 	session_start();
> 
> 
> 	/// Define some $_SESSION variables
> 	$_SESSION['sessionid'] = session_id() ;
> 	$_SESSION['server'] = "http://localhost/~user/new_project"; ;
> 	$_SESSION['sql_dflts'] = $_SESSION['server']."/sql/sql_dflts.inc" ;
> 	$_SESSION['remoteaddr'] = $_SERVER['REMOTE_ADDR'] ;
> 	$_SESSION['remotehost'] = gethostbyaddr ( $_SERVER['REMOTE_ADDR'] ) ;
> 
> 	/// Include Files
> 	include ( $_SESSION['sql_dflts'] ) ;
> 	include ( $_SESSION['server']."/fnc/fnc_include_dir.inc" ) ;
> 	$var_include_dir = include_dir ( "fnc" ) ;
> 
> ?>
> ### END CODE SNIPPET #########################################################
> 
> All of the projects I have done so far were for business intranet purposes and
> it worked fine. But last week I uploaded another project to the internet and my
> sessions did not work.
> 
> I have been using it this way since v4.0 (I think, anyway since a LONG time
> ago), but now I think it is a bit outdated and needs some kind of revision. Is
> this still sufficient or can you guys give some tips on a more "updated" way of
> starting my sessions?
> 
> My php.ini file is stock-standard. I am running version 5.2.6-1 with apache
> 2.2.9 on a Debian 5.04 machine.

Nothing looks to be wrong with the session initiation code.  The problem is more
the likely the calls to include a remote file.  Basically, to expand your
variables out, you would be doing this:

include ( 'http://localhost/~user/new_project/sql/sql_dflts.inc' ) ;
include ( 'http://localhost/~user/new_project/fnc/fnc_include_dir.inc' ) ;

If your php.ini settings are stock, then the problem is with the
allow_url_include directive.  It is set to "0" by default.

See here: http://us3.php.net/manual/en/filesystem.configuration.php

Change that setting to '1' and restart your web server, then you should be good
to go.

> 
> Thank You
> 
> Danny
> 


-- 
Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux