468,248 Members | 1,470 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,248 developers. It's quick & easy.

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 1275

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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Sticks | last post: by
6 posts views Thread by Alex Vilner | last post: by
3 posts views Thread by randommale9999 | last post: by
8 posts views Thread by C. (http://symcbean.blogspot.com/) | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.