note 85021 modified in book.session by felipe

From: Date: Mon, 11 Aug 2008 14:34:04 +0000
Subject: note 85021 modified in book.session by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143360@lists.php.net to get a copy of this message
Persistence of session data in included file also has one more aspects if you are including a file using/over the http connection. Session will not be available without refresh (it's a separate thread even if you are on the same domain/server), which is again a correct behavior, but if you are including a file from local file system then it should have session data if you are setting and accessing the $_SESSION variable even before page refresh because it is available globally. <?php session_start(); $_SESSION['example']="yes"; Include("otherfile"); ?> Session variable will be available in included file. <?php session_start(); $_SESSION['example']="yes"; Include("http://domain.com/otherfile.php"); ?> Session will NOT be available in other file. BUt if both files are on same server then after refresh values will be available. --was-- Persistence of session data in included file also has one more aspects if you are including a file using/over the http connection. Session will not be available without refresh (it's a separate thread even if you are on the same domain/server), which is again a correct behavior, but if you are including a file from local file system then it should have session data if you are setting and accessing the $_SESSION variable even before page refresh because it is available globally. [code] session_start(); $_SESSION['example']="yes"; Include("otherfile"); [/code] Session variable will be available in included file. [code] session_start(); $_SESSION['example']="yes"; Include("http://domain.com/otherfile.php"); [/code] Session will NOT be available in other file. BUt if both files are on same server then after refresh values will be available. http://php.net/manual/en/book.session.php

« previous php.notes (#143360) next »