473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

running scripts without session

When I run my scripts on a http server I can use the
$_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have my
local file system laid out exactly as the one on my server.

The issue is that when I run the script without using session_start I have
to set the document root manually. Now every time I switch from running
locally to a web server I have to comment out the line. Its not a big deal
but I'm wonder if I could somehow tell php to use a default document root if
a session isn't started?

Thanks,
Jon
Jun 17 '07 #1
7 1392

Jon Slaughter :
When I run my scripts on a http server I can use the
$_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have my
local file system laid out exactly as the one on my server.

The issue is that when I run the script without using session_start I have
to set the document root manually. Now every time I switch from running
locally to a web server I have to comment out the line. Its not a big deal
but I'm wonder if I could somehow tell php to use a default document root if
a session isn't started?

Thanks,
Jon
<?php
/**
* May be something like this ?
* When function session_start()
* is not called or not successed
* $_SESSION is not set.
*/

$docRoot = isset($_SESSION) ? $_SESSION['Document_Root'] :
$_SERVER['DOCUMENT_ROOT'];
?>

Jun 17 '07 #2

"zono" <go******@gmail.comwrote in message
news:11*********************@c77g2000hse.googlegro ups.com...
>
Jon Slaughter :
>When I run my scripts on a http server I can use the
$_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have
my
local file system laid out exactly as the one on my server.

The issue is that when I run the script without using session_start I
have
to set the document root manually. Now every time I switch from running
locally to a web server I have to comment out the line. Its not a big
deal
but I'm wonder if I could somehow tell php to use a default document root
if
a session isn't started?

Thanks,
Jon
<?php
/**
* May be something like this ?
* When function session_start()
* is not called or not successed
* $_SESSION is not set.
*/

$docRoot = isset($_SESSION) ? $_SESSION['Document_Root'] :
$_SERVER['DOCUMENT_ROOT'];
?>
lol
duh... can't believe I didn't think about that ;/

Thanks,
Jon
Jun 17 '07 #3

"zono" <go******@gmail.comwrote in message
news:11*********************@c77g2000hse.googlegro ups.com...
>
Jon Slaughter :
>When I run my scripts on a http server I can use the
$_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have
my
local file system laid out exactly as the one on my server.

The issue is that when I run the script without using session_start I
have
to set the document root manually. Now every time I switch from running
locally to a web server I have to comment out the line. Its not a big
deal
but I'm wonder if I could somehow tell php to use a default document root
if
a session isn't started?

Thanks,
Jon
<?php
/**
* May be something like this ?
* When function session_start()
* is not called or not successed
* $_SESSION is not set.
*/

$docRoot = isset($_SESSION) ? $_SESSION['Document_Root'] :
$_SERVER['DOCUMENT_ROOT'];
?>
hmm, actually it doesn't work. because I use session_start(); I get a
document root... just not the correct one. I guess I have to find some
setting to change in the local http server the debugger uses.

Thanks,
Jon
Jun 17 '07 #4

"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:t1*****************@newssvr19.news.prodigy.ne t...
When I run my scripts on a http server I can use the
$_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have
my local file system laid out exactly as the one on my server.

The issue is that when I run the script without using session_start I have
to set the document root manually. Now every time I switch from running
locally to a web server I have to comment out the line. Its not a big deal
but I'm wonder if I could somehow tell php to use a default document root
if a session isn't started?

Thanks,
Jon
ok, nm... was a setting in the server config.

Jun 17 '07 #5

Jon Slaughter :
"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:t1*****************@newssvr19.news.prodigy.ne t...
When I run my scripts on a http server I can use the
$_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have
my local file system laid out exactly as the one on my server.

The issue is that when I run the script without using session_start I have
to set the document root manually. Now every time I switch from running
locally to a web server I have to comment out the line. Its not a big deal
but I'm wonder if I could somehow tell php to use a default document root
if a session isn't started?

Thanks,
Jon

ok, nm... was a setting in the server config.
Hm.
Did you see value of $_SERVER['DOCUMENT_ROOT'] ?
May be it can help you.

Jun 17 '07 #6
On Jun 17, 3:41 am, "Jon Slaughter" <Jon_Slaugh...@Hotmail.comwrote:
"zono" <gonau...@gmail.comwrote in message

news:11*********************@c77g2000hse.googlegro ups.com...


Jon Slaughter :
When I run my scripts on a http server I can use the
$_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have
my
local file system laid out exactly as the one on my server.
The issue is that when I run the script without using session_start I
have
to set the document root manually. Now every time I switch from running
locally to a web server I have to comment out the line. Its not a big
deal
but I'm wonder if I could somehow tell php to use a default document root
if
a session isn't started?
Thanks,
Jon
<?php
/**
* May be something like this ?
* When function session_start()
* is not called or not successed
* $_SESSION is not set.
*/
$docRoot = isset($_SESSION) ? $_SESSION['Document_Root'] :
$_SERVER['DOCUMENT_ROOT'];
?>

lol
duh... can't believe I didn't think about that ;/

Thanks,
Jon
Why wouldn't you just /always/ use $_SERVER['DOCUMENT_ROOT'] ?

Jun 17 '07 #7

"ZeldorBlat" <ze********@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
On Jun 17, 3:41 am, "Jon Slaughter" <Jon_Slaugh...@Hotmail.comwrote:
>"zono" <gonau...@gmail.comwrote in message

news:11*********************@c77g2000hse.googlegr oups.com...


Jon Slaughter :
When I run my scripts on a http server I can use the
$_SESSION['Document_Root'] to get the dir of the scripts and stuff(I
have
my
local file system laid out exactly as the one on my server.
>The issue is that when I run the script without using session_start I
have
to set the document root manually. Now every time I switch from
running
locally to a web server I have to comment out the line. Its not a big
deal
but I'm wonder if I could somehow tell php to use a default document
root
if
a session isn't started?
>Thanks,
Jon
<?php
/**
* May be something like this ?
* When function session_start()
* is not called or not successed
* $_SESSION is not set.
*/
$docRoot = isset($_SESSION) ? $_SESSION['Document_Root'] :
$_SERVER['DOCUMENT_ROOT'];
?>

lol
duh... can't believe I didn't think about that ;/

Thanks,
Jon

Why wouldn't you just /always/ use $_SERVER['DOCUMENT_ROOT'] ?
You should I guess. I didn't see that it was getting set locally for some
reason and didn't realize that it was pointing to the wrong place. Was just
being stupid ;/

Jun 17 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Sticks | last post by:
ok... im not quite sure how to describe my problem. i have a php script that runs through my entire php site and writes the resulting output to html files. this is necessary as the nature of the...
0
by: Vince C. | last post by:
Hi. I'm using Visual Interdev 6 (SP5) to server-side debug my ASP scripts. I'd like to detect whether I'm running the script under a debugging session or not. The detection should work on...
6
by: Alex Vilner | last post by:
Hello! We have a set of individual .SQL scripts which we would like to execute against a MS SQL Server 2000. Is there any way to have ISQL utility (or any other means) to execute all of them...
0
by: Valentin Guggiana | last post by:
Hi all I build MySQL 5.0.24 as follows: setenv PREFIX /data/mysql-5.0.24 setenv CFLAGS "-O3 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" setenv CXXFLAGS "$CFLAGS -felide-constructors...
3
by: randommale9999 | last post by:
I was wondering how people are able to create ajax applications like star ratings scripts without having bots hit the scripts. I have a star rating script on my site which was getting hit by bots....
4
by: Christoph | last post by:
A while ago, I implemented an AJAX-based progress bar on a web page that executed a lengthy server operation. The web page was a Java servlet on a Tomcat server. The progress bar worked by...
8
by: C. (http://symcbean.blogspot.com/) | last post by:
Hi all, I am looking for a way to run PHP scripts without using a webserver (from a MS Windows machine). While there are shareware solutions for doing this, it strikse me that it might be...
3
by: John | last post by:
Hi. I have a number of batch jobs that are ran nightly on our Windows 2000 based Oracle 8.1.7 (soon to be 9i) server. I have these designed just right, so the Windows Scheduled Tasks runs them...
0
by: eddiefisher41 | last post by:
Hey guys. Im having problems running a python cgi. Im using the example code from: http://www.python.org/doc/essays/ppt/sd99east/sld041.htm as writen by Van Rossum himself I can get the script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.