Hi. Im very new to php, and I have a problem here that I cant find the
solution for. I have problems with session variables, I want some
variables to maintain their value between different php script that is
being called. I have read the online manual, and here is an example from
it that doesnt work for me, it illustrates very well my problem.
File 1, index.php
<?php
// index.php
session_start();
echo '<br />Welcome to page #1';
$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();
// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';
// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
?>
File 2, page2.php
<?php
// page2.php
session_start();
echo '<br />Welcome to page #2<br />';
echo $_SESSION['favcolor']; // green
echo $_SESSION['animal']; // cat
echo date('Y m d H:i:s', $_SESSION['time']);
// You may want to use SID here, like we did in page1.php
echo '<br /><a href="index.php">page 1</a>';
?>
I get no output, except the date which shows 1970 bla bla
I have apache 2.0.48, PHP 4.3.3 running on a Redhat 9.0 box. I have not
touched the register_globals in php.ini, it's Off. What can be the problem
here ? Any help would be much appreciated, I'm stuck....
Thanx
/ZoombyWoof 18 8283
ZoombyWoof wrote:
[...] I get no output, except the date which shows 1970 bla bla
I have apache 2.0.48, PHP 4.3.3 running on a Redhat 9.0 box. I have not touched the register_globals in php.ini, it's Off. What can be the problem here ? Any help would be much appreciated, I'm stuck....
What do you have for "session.save_path" in php.ini?
Does the webserver have write-access to that directory?
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
On Tue, 04 Nov 2003 15:32:14 +0000, Pedro wrote: ZoombyWoof wrote: [...] I get no output, except the date which shows 1970 bla bla
I have apache 2.0.48, PHP 4.3.3 running on a Redhat 9.0 box. I have not touched the register_globals in php.ini, it's Off. What can be the problem here ? Any help would be much appreciated, I'm stuck....
What do you have for "session.save_path" in php.ini? Does the webserver have write- permissions are
rwxrwxrwxt owned by root, so that shouldnt be a problem, or ?
/ZW
ZoombyWoof <zo**************@thishotmail.com> wrote: Hi. Im very new to php, and I have a problem here that I cant find the solution for. I have problems with session variables, I want some variables to maintain their value between different php script that is being called. I have read the online manual, and here is an example from it that doesnt work for me, it illustrates very well my problem.
// Or maybe pass along the session id, if needed echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
The above will only work if you set session.use_trans_sid in php.ini to 1.
Furthermore cookies must be accepted by your browser in order to work.
Alternatively you could use:
echo '<br /><a href="page2.php?'.session_name().'='.session_id(). '">page
2</a>';
Check the session cookie on page 2 with session_get_cookie_params() .. if
that's empty, the cookie hasn't been set. http://uk.php.net/manual/en/function...kie-params.php
HTH;
JOn
--
Begathon, n.:
A multi-day event on public television, used to raise money so
you won't have to watch commercials.
On Tue, 04 Nov 2003 15:35:08 +0000, Jon Kraft wrote: ZoombyWoof <zo**************@thishotmail.com> wrote:
Hi. Im very new to php, and I have a problem here that I cant find the solution for. I have problems with session variables, I want some variables to maintain their value between different php script that is being called. I have read the online manual, and here is an example from it that doesnt work for me, it illustrates very well my problem.
// Or maybe pass along the session id, if needed echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
The above will only work if you set session.use_trans_sid in php.ini to 1. Furthermore cookies must be accepted by your browser in order to work.
Alternatively you could use:
echo '<br /><a href="page2.php?'.session_name().'='.session_id(). '">page 2</a>';
Check the session cookie on page 2 with session_get_cookie_params() .. if that's empty, the cookie hasn't been set.
http://uk.php.net/manual/en/function...kie-params.php
HTH; JOn
I have tried all of what you suggested above, setting use_trans_sid to 1
didnt help. I used the link with session_name=session_id, didnt help. I
have changed session.save_path to /usr/local/apache2/sessions, apache owns
that directory, apache is the user who runs the server, but nothing goes
in that directory. I have checked the cookie_params, and it doesnt contain
anything else from what is set as default in php.ini.
I dont understand this....*HELP* :-)
Thanx
/ZW
ZoombyWoof <zo**************@thishotmail.com> wrote: I have tried all of what you suggested above, setting use_trans_sid to 1 didnt help. I used the link with session_name=session_id, didnt help. I have changed session.save_path to /usr/local/apache2/sessions, apache owns that directory, apache is the user who runs the server, but nothing goes in that directory. I have checked the cookie_params, and it doesnt contain anything else from what is set as default in php.ini. I dont understand this....*HELP* :-)
Hm, strange, are you sure you are editing the php.ini PHP uses? Check with
phpinfo(). That will also tell you whether PHP was compiled with
--disable-session.
JOn
--
He only knew his iron spine held up the sky -- he didn't realize his brain
had fallen to the ground.
-- The Book of Serenity
On Tue, 04 Nov 2003 18:15:12 +0000, Jon Kraft wrote: ZoombyWoof <zo**************@thishotmail.com> wrote:
I have tried all of what you suggested above, setting use_trans_sid to 1 didnt help. I used the link with session_name=session_id, didnt help. I have changed session.save_path to /usr/local/apache2/sessions, apache owns that directory, apache is the user who runs the server, but nothing goes in that directory. I have checked the cookie_params, and it doesnt contain anything else from what is set as default in php.ini. I dont understand this....*HELP* :-)
Hm, strange, are you sure you are editing the php.ini PHP uses? Check with phpinfo(). That will also tell you whether PHP was compiled with --disable-session.
JOn
Yes, I'm editing the one PHP is using, it's /etc/php.ini, however, if you
mean that it should say --disable-session under configure command at the
top, it doesnt. Do I have to have disable-session compiled in ? Why is
this not the default, if it's necessary to get session to work...?
Thanx
/ZW
ZoombyWoof wrote: On Tue, 04 Nov 2003 15:35:08 +0000, Jon Kraft wrote:
ZoombyWoof <zo**************@thishotmail.com> wrote:
Hi. Im very new to php, and I have a problem here that I cant find the solution for. I have problems with session variables, I want some variables to maintain their value between different php script that is being called. I have read the online manual, and here is an example from it that doesnt work for me, it illustrates very well my problem.
// Or maybe pass along the session id, if needed echo '<br /><a href="page2.php?' . SID . '">page 2</a>'; The above will only work if you set session.use_trans_sid in php.ini to 1. Furthermore cookies must be accepted by your browser in order to work.
Alternatively you could use:
echo '<br /><a href="page2.php?'.session_name().'='.session_id(). '">page 2</a>';
Check the session cookie on page 2 with session_get_cookie_params() .. if that's empty, the cookie hasn't been set.
http://uk.php.net/manual/en/function...kie-params.php
HTH; JOn
I have tried all of what you suggested above, setting use_trans_sid to 1 didnt help.
Did you restart the webserver after editing php.ini? That's a commonly
overlooked step...
I used the link with session_name=session_id, didnt help. I have changed session.save_path to /usr/local/apache2/sessions, apache owns that directory, apache is the user who runs the server, but nothing goes in that directory. I have checked the cookie_params, and it doesnt contain anything else from what is set as default in php.ini.
Be sure that session.auto_start is off.
session.save_handler needs to be set to files for session.save_path to
be used.
session.use_cookies should be on if you want to use cookies. If you want
to use *only* cookies, then session.use_only_cookies should be on as well.
Make sure that session.gc_maxlifetime isn't set really low (default is
1440 seconds, or 24 minutes). Same with session.cookie_lifetime, but 0
is no exipre in this case. (Watch for session.cache_expire as well.)
--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
ZoombyWoof wrote: On Tue, 04 Nov 2003 18:15:12 +0000, Jon Kraft wrote:
ZoombyWoof <zo**************@thishotmail.com> wrote:
I have tried all of what you suggested above, setting use_trans_sid to 1 didnt help. I used the link with session_name=session_id, didnt help. I have changed session.save_path to /usr/local/apache2/sessions, apache owns that directory, apache is the user who runs the server, but nothing goes in that directory. I have checked the cookie_params, and it doesnt contain anything else from what is set as default in php.ini. I dont understand this....*HELP* :-)
Hm, strange, are you sure you are editing the php.ini PHP uses? Check with phpinfo(). That will also tell you whether PHP was compiled with --disable-session.
Yes, I'm editing the one PHP is using, it's /etc/php.ini, however, if you mean that it should say --disable-session under configure command at the top, it doesnt. Do I have to have disable-session compiled in ? Why is this not the default, if it's necessary to get session to work...?
If id did say --disable-session, then sessions would be disabled and not
available on the server.
Check the under phpinfo() for "Configuration File (php.ini) Path" and be
sure that it is set to /etc/php.ini, otherwise all your edits will do
nothing. Also be sure to restart apache after editing.
--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
On Tue, 04 Nov 2003 18:27:23 +0000, Justin Koivisto wrote: ZoombyWoof wrote:
*snip* Did you restart the webserver after editing php.ini? That's a commonly overlooked step...
Oh yes I did.
*snip* Be sure that session.auto_start is off.
It is session.save_handler needs to be set to files for session.save_path to be used.
It is session.use_cookies should be on if you want to use cookies. If you want to use *only* cookies, then session.use_only_cookies should be on as well.
Cookies is on Make sure that session.gc_maxlifetime isn't set really low (default is 1440 seconds, or 24 minutes). Same with session.cookie_lifetime, but 0 is no exipre in this case. (Watch for session.cache_expire as well.)
Default values
/ZW
On Tue, 04 Nov 2003 18:29:44 +0000, Justin Koivisto wrote: ZoombyWoof wrote:
On Tue, 04 Nov 2003 18:15:12 +0000, Jon Kraft wrote:
ZoombyWoof <zo**************@thishotmail.com> wrote:
I have tried all of what you suggested above, setting use_trans_sid to 1 didnt help. I used the link with session_name=session_id, didnt help. I have changed session.save_path to /usr/local/apache2/sessions, apache owns that directory, apache is the user who runs the server, but nothing goes in that directory. I have checked the cookie_params, and it doesnt contain anything else from what is set as default in php.ini. I dont understand this....*HELP* :-)
Hm, strange, are you sure you are editing the php.ini PHP uses? Check with phpinfo(). That will also tell you whether PHP was compiled with --disable-session.
Yes, I'm editing the one PHP is using, it's /etc/php.ini, however, if you mean that it should say --disable-session under configure command at the top, it doesnt. Do I have to have disable-session compiled in ? Why is this not the default, if it's necessary to get session to work...?
If id did say --disable-session, then sessions would be disabled and not available on the server.
Check the under phpinfo() for "Configuration File (php.ini) Path" and be sure that it is set to /etc/php.ini, otherwise all your edits will do nothing. Also be sure to restart apache after editing.
It did not say --disable_session and I edit the right file.
THis is really weird...
/ZW
At this point, I say post a link to a phpinfo() call so we can better
see what is going on.
--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
On Tue, 04 Nov 2003 19:39:25 +0000, Justin Koivisto wrote: At this point, I say post a link to a phpinfo() call so we can better see what is going on.
THis wull be opened a couple of hours, then I close it again. http://zoombywoof.dns2go.com:8029/phpinfo.php
Thanx
/ZW
ZoombyWoof wrote: THis wull be opened a couple of hours, then I close it again.
http://zoombywoof.dns2go.com:8029/phpinfo.php
session_cookie_path = /
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
I wrote, way too fast: session_cookie_path = /
session.cookie_path = /
session.save_path is local to the webserver filesystem.
session.cookie_path is the HTTP path sent to the client in the cookie.
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
On Tue, 04 Nov 2003 20:18:12 +0000, Pedro wrote: I wrote, way too fast: session_cookie_path = / session.cookie_path = /
session.save_path is local to the webserver filesystem.
session.cookie_path is the HTTP path sent to the client in the cookie.
I had it set to /, I just tried and changed, it didnt do any difference.
I'll change it back.
/ZW
ZoombyWoof wrote: I'll change it back.
Is it working now?
I just noticed -- at the locally cached phpinfo -- you did not have
session.save_handler = files
Maybe you have already changed that too :)
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
On Tue, 04 Nov 2003 22:54:58 +0000, Pedro wrote: ZoombyWoof wrote: I'll change it back.
Is it working now?
I just noticed -- at the locally cached phpinfo -- you did not have
session.save_handler = files
Maybe you have already changed that too :)
:-)))))) Its working now! You were right, I had session.save_handler =
file instead of session.save_handler = files (pluralis)
The script works, the variables are echoed correctly in page2.php But, I
get this warning :
Warning: session_start(): Cannot send session cookie - headers already
sent by (output started at /usr/local/apache2/htdocs/phptest/page2.php:4)
in /usr/local/apache2/htdocs/phptest/page2.php on line 7
Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at
/usr/local/apache2/htdocs/phptest/page2.php:4) in
/usr/local/apache2/htdocs/phptest/page2.php on line 7
What does this mean ?
Thanx for the help.
/ZW
On Wed, 05 Nov 2003 00:05:42 +0100, ZoombyWoof wrote: On Tue, 04 Nov 2003 22:54:58 +0000, Pedro wrote:
ZoombyWoof wrote: I'll change it back.
Is it working now?
I just noticed -- at the locally cached phpinfo -- you did not have
session.save_handler = files
Maybe you have already changed that too :)
:-)))))) Its working now! You were right, I had session.save_handler = file instead of session.save_handler = files (pluralis)
The script works, the variables are echoed correctly in page2.php But, I get this warning :
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /usr/local/apache2/htdocs/phptest/page2.php:4) in /usr/local/apache2/htdocs/phptest/page2.php on line 7
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /usr/local/apache2/htdocs/phptest/page2.php:4) in /usr/local/apache2/htdocs/phptest/page2.php on line 7
What does this mean ?
Thanx for the help.
/ZW
I solved it. I had an echo line before session_start, which according to
the php manual is Not allowed. Not everything is HunkyDory :-))
Thanx again everyone that answered me and tried to help me.
/ZoombyWoof This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mimi |
last post by:
Hello,
I am having trouble using the session vars in
PHP 4.3.9
OS: Win XP Prof
Web Server IIS (is local and there are no links to other servers from
the web pages I work on)
Browser: IE 6.0
...
|
by: Jonathan Chong |
last post by:
I have problem with AOL browser (IE and Netscape are OK) accessing my Web
site after putting up a load balancer that will go to W1 or W2.
The problem does not happen when there is only Web server...
|
by: Gary |
last post by:
I am having a strange problem that I cannot solve. I have an asp page that I use for a user to login and gain access to other pages. When the user logs in I set a couple of session variables like...
|
by: Adam Short |
last post by:
I'm having all sorts of problems with Sessions, I've been using them for
years with out a hitch, all of a sudden the last 6 - 12 months since getting
our new Win2003 server it's all gone shakey!!!...
|
by: Newton |
last post by:
Hi,
I got here the following problem. I am programming
web application for examing students.
After student will log on I need to keep his ID,
Privileges, Login, Password for manipulating with...
|
by: Scott Zabolotzky |
last post by:
I'm trying to pass a custom object back and forth between forms.
This custom object is pulled into the app using an external reference
to an assembly DLL that was given to me by a co-worker. A...
|
by: Ashish |
last post by:
Incase the problem got bogged down reposting...
Hi Gregory,
I think I didnt make myself much clear. The problem is:
1. I have one ASP.NET application (no classic asp) and it has a main page...
|
by: Alexander Widera |
last post by:
hello all,
i have a problem ...
like I already discussed in the thread "session empty" I have the following
problem:
I created a completely new web...
i added 2 files:
sessiontest1.aspx:
|
by: stclaus |
last post by:
Hi,
I'm currently experiencing a problem using sessions under php 4.4.2. I
store variables and objects inside session variables, and all works
well under php 5.x, but when I upload those pages to...
|
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...
|
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,...
|
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...
|
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,...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |