From: Gaurav Kumar on
Danny,

I just read the email trail regarding your problem.

The very first thing-
1. Session are stored as a file on the server in a folder. Check that the
folder has read/*write* permission. (/tmp/ folder)
2. Check on the server that are the sessions really getting saved on the
server?
3. Now in case you do not have access to a sessions folder on the server
then set the session folder name/path to the folder (a new one) you can have
access to (may be root of your ftp) using
session_save_path('/httpdocs/'your-domain-folder/new-session-folder)
(provide read/write permission) before session_start() in index.php or
common header include file. This session_save_path() should be declared on
every file on the top.

Try the above and let me know if it works.

Thanks,
Gaurav Kumar

http://blog.OsWebStudio.Com





On Thu, Jun 24, 2010 at 7:54 PM, Danny <dannydebont(a)gmail.com> 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<http://localhost/%7Euser/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.
>
> Thank You
>
> Danny
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
From: Jim Lucas on
Danny wrote:
> Thanks Ashley and Jim,
>
>> When you say 'sessions did not work' what do you mean? Sessions aren't being
>> created? You can't access session variables? You need to be a bit more specific
>> about the issue.
>
> Sorry, here is an explanation:
>
> The project I uploaded for a customer is a "stock ordering" web-app that they used
> on their local intranet for a year or so, but now they want this same web-app to
> be available globally.
>
> I thought that it would work "out-the-box" on the internet but it doesn't. On
> their local-lan I am able to do some (advanced) login checks with sessions with no
> problem, like I said, it has been workng for a year or so now. Also, the same
> login sequence I use here I also use in my other intranet web-apps.
>
> However, when I uploaded this project and I log on, I just get a blank screen
> after the login checks are done and it is supposed to take me to the logged-in
> start page.

Regarding the blank page, in your php.ini file turn on display_errors and
error_reporting

error_reporting = E_ALL
display_errors = On

This will make sure that PHP tells you all the errors that are possibly being
generated.

>
> That is why I say that somehow my sessions are not "carried over" or "caught" by php.
>
> Thanks for the comments on my session initialization, if there is not really
> anything that should be changed, then I will leave it like it is.
>
> Just one more thing, should I always expand the URL's to an absolute path
> instead of using a session variable like I do?
>
> Thnks again guys
>
> 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?
From: Danny on
Hi Gaurav,

Creating a "local" folder solved the problem. I can now catch the session
varaibles.

I think that I am too familiar with setting up everything on a local server and
forgot that there are "other" things to consider when you work on the internet.

Thank You

Danny
>On Jun 25 10, Gaurav Kumar :
> 2. Check on the server that are the sessions really getting saved on the
> server?
> 3. Now in case you do not have access to a sessions folder on the server then
> set the session folder name/path to the folder (a new one) you can have access
> to (may be root of your ftp) using session_save_path('/httpdocs/
> 'your-domain-folder/new-session-folder) (provide read/write permission) before
> session_start() in index.php or common header include file. This
> session_save_path() should be declared on every file on the top.
>
> Try the above and let me know if it works.
>
From: Danny on
Hi Jim,

I followed Gaurav's tips on creating a "folder" to store the session info in and
it got solved. I can now catch the session variables but I got A LOT of "include()"
file errors which was solved by following your suggestion on expanding my URL's.

Thank You

Danny

>On Jun 24 10, Jim Lucas :
>
> 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.
>
From: Danny on
Hi Mari,

I used "localhost" as a substitute for the real url. My mistake I should've told
you guys. Thanks anyway for your input.

Danny
>On Jun 24 10, Mari Masuda :
>
> Maybe you need to change
>
> $_SESSION['server'] = "http://localhost/~user/new_project" ;
>
> to be not localhost.