473,386 Members | 1,779 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.

Session problems

Hi there...

I've got a problem where a normal string variable loses its value after
session_start() is called. The funny thing is, that this only happens
for some people, and they are using IE6, but it does not happen with all
versions of IE6. I've tested myself only with Mozilla and IE5, but the
problem does not occur for me.

I've got a username stored in $user, which is obtained from the $_POST
variable, but after session_start() is called $user is empty, but the
username still is in $_POST['username'].

PHP version is 4.3.1 on Apache on a linux server.
Then another problem I have is being logged out from a session after a
certain length of inactivity it would seem. I've only noticed this on
a server which is running PHP 4.3.3/Apache 1.3.28/linux. It's about
after half an hour of inactivity that I get logged out. I've checked
the cookie and it is set to expire on session/browser exit. I haven't
noticed this behavior on my own server also running PHP 4.3.3. I also
checked the PHP session configuration and it's the same on both servers.

So, any ideas what could be causing this...?
Thanks for any help,
Daniel Bengs

Jul 17 '05 #1
6 4391
Daniel Bengs <a-****@non-existing-e-mail-adress.com> schrieb:
I've got a problem where a normal string variable loses its value after
session_start() is called. The funny thing is, that this only happens
for some people, and they are using IE6, but it does not happen with all
versions of IE6. I've tested myself only with Mozilla and IE5, but the
problem does not occur for me.
Very strange. PHP is running on the server, not on the browser.
I've got a username stored in $user, which is obtained from the $_POST
variable, but after session_start() is called $user is empty, but the
username still is in $_POST['username'].
This is one of the problems if register_globals is activated. Could you
check this?
Then another problem I have is being logged out from a session after a
certain length of inactivity it would seem. I've only noticed this on
a server which is running PHP 4.3.3/Apache 1.3.28/linux. It's about
after half an hour of inactivity that I get logged out. I've checked
the cookie and it is set to expire on session/browser exit. I haven't
noticed this behavior on my own server also running PHP 4.3.3. I also
checked the PHP session configuration and it's the same on both servers.


Sure? What's the value of session.gc_maxlifetime and
session.gc_probability = 1 in the php.ini?

Regards,
Matthias
Jul 17 '05 #2
Matthias Esken wrote:
Daniel Bengs <a-****@non-existing-e-mail-adress.com> schrieb:

I've got a problem where a normal string variable loses its value after
session_start() is called. The funny thing is, that this only happens
for some people, and they are using IE6, but it does not happen with all
versions of IE6. I've tested myself only with Mozilla and IE5, but the
problem does not occur for me.

Very strange. PHP is running on the server, not on the browser.

I've got a username stored in $user, which is obtained from the $_POST
variable, but after session_start() is called $user is empty, but the
username still is in $_POST['username'].

This is one of the problems if register_globals is activated. Could you
check this?


Yes, according to phpinfo() register globals is on.
Then another problem I have is being logged out from a session after a
certain length of inactivity it would seem. I've only noticed this on
a server which is running PHP 4.3.3/Apache 1.3.28/linux. It's about
after half an hour of inactivity that I get logged out. I've checked
the cookie and it is set to expire on session/browser exit. I haven't
noticed this behavior on my own server also running PHP 4.3.3. I also
checked the PHP session configuration and it's the same on both servers.

Sure? What's the value of session.gc_maxlifetime and
session.gc_probability = 1 in the php.ini?


session.gc_maxlifetime 1440
session.gc_probability 1

....according to phpinfo() at least...

Jul 17 '05 #3
Daniel Bengs wrote:
Matthias Esken wrote:
Daniel Bengs <a-****@non-existing-e-mail-adress.com> schrieb:

I've got a problem where a normal string variable loses its value
after session_start() is called. The funny thing is, that this only
happens for some people, and they are using IE6, but it does not
happen with all versions of IE6. I've tested myself only with Mozilla
and IE5, but the problem does not occur for me.


Very strange. PHP is running on the server, not on the browser.

I've got a username stored in $user, which is obtained from the $_POST
variable, but after session_start() is called $user is empty, but the
username still is in $_POST['username'].


This is one of the problems if register_globals is activated. Could you
check this?

Yes, according to phpinfo() register globals is on.


What's also common for the people in this case is that they are on an
internal network, not that I understand why that would make any
difference either... :)

And now I also noticed another funny thing. On one page where an
addition to a mysql database is made a field, which is the user who made
the addition, is empty for some persons, but not everyone who makes the
addition. The username value is retrieved with:

"((string) $_SESSION['username'])".

But when the username, on the same page, is written to a logfile, with
the same code above, it is not empty.

Jul 17 '05 #4
Daniel Bengs <a-****@non-existing-e-mail-adress.com> schrieb:
And now I also noticed another funny thing. On one page where an
addition to a mysql database is made a field, which is the user who made
the addition, is empty for some persons, but not everyone who makes the
addition. The username value is retrieved with:

"((string) $_SESSION['username'])".

But when the username, on the same page, is written to a logfile, with
the same code above, it is not empty.


Does the problem occur while displaying the data or storing the data in
the database.

In the second case, there might be some special chars like ' in the
username. Always use mysql_escape_string() for values that you want to
send to the MySQL server.

Regards,
Matthias
Jul 17 '05 #5
Daniel Bengs <a-****@non-existing-e-mail-adress.com> schrieb:
Matthias Esken wrote:
Sure? What's the value of session.gc_maxlifetime and
session.gc_probability = 1 in the php.ini?


session.gc_maxlifetime 1440
session.gc_probability 1


So the session is considered invalid after 1440 seconds of inactivity
which are 24 minutes. With a probability of 1% the session is killed
during a session initialization. If not, you can continue to use the
session. If a lot of requests hit the server, the probability that the
idling session is killed after 30 minutes is very high. If you're just
testing your code with one user, it might take longer. Increase
session.gc_maxlifetime if you need more time.

Regards,
Matthias
Jul 17 '05 #6
Matthias Esken <mu******************@usenetverwaltung.org> wrote in message news:<bn**********@usenet.esken.de>...
Daniel Bengs <a-****@non-existing-e-mail-adress.com> schrieb:
And now I also noticed another funny thing. On one page where an
addition to a mysql database is made a field, which is the user who made
the addition, is empty for some persons, but not everyone who makes the
addition. The username value is retrieved with:

"((string) $_SESSION['username'])".

But when the username, on the same page, is written to a logfile, with
the same code above, it is not empty.
Does the problem occur while displaying the data or storing the data in
the database.


Displaying it... anyway, it seems that it works better now when I
moved the session_start to the top of the code, but I still didn't
have any code that was outputting anything...
In the second case, there might be some special chars like ' in the
username. Always use mysql_escape_string() for values that you want to
send to the MySQL server.


None of the usernames have any special characters...
PS. My news server didn't get the last two posts (besides a whole lot
other posts it doesn't get) and therefore I haven't answered before
now. So I'm using Google groups now instead...
Jul 17 '05 #7

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

Similar topics

27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
7
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!!!...
3
by: Nicolae Fieraru | last post by:
Hi All, I have a lot of problems with the web site www.ggsurf.com.au I host on www.gnxonline.com and I want to find out if it is my own problem or theirs. I try to use session cookies and it...
3
by: headware | last post by:
I have an issue that I've been encountering in an ASP application I'm working on. Most of the application is written in ASP, but there is one page written in ASP.NET. The ASP.NET page needs to have...
3
by: Craig Storey | last post by:
I have a form where users logged in using sessions can edit articles in a WYSIWYG editor. Some of them take their time and don't like to save their work very often and occassionally the sessions...
3
by: Scott | last post by:
Hello, we are having problems displaying non-aspx files (images, style sheets) since we have upgraded to the 1.1 framework when using a cookieless session (sessionID in the url). Check out...
9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
13
by: Alexander Widera | last post by:
hi, who has seen the follow problem or could help please? i visit a page .... i read a sesssion-var . ... everythink works...... i visit the page again..... error ... the sessionvar is null .... i...
18
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
1
by: KidQuin | last post by:
I am having problems with session value between pages. Happening in both firefox and IE7. I go between page by links so I know it's not header changes. I use session_start as the first line on the...
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.