473,403 Members | 2,293 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,403 software developers and data experts.

Sessions Question

Hi folks,

I've got a question about sessions in PHP. I'm a *gulp* ASP coder, so
please bear with me.

I developed a PHP site a few months back that has a password protected
entry into a secure section. I'm using session variables to ensure
that track if a visitor has already logged in, and should therefore be
allowed to view a given page.

This week there was a problem with the site not having access to the
MySQL database the site uses. The hosting company sent me this message
as an explanation for the problem:

"the culprit seems to be the way that you are handing sessions on the
GPR_intro.php page. The sessions are not being terminated in a timely
manner which is causing a back log of processes on the MySQL service
and is causing it to fail. The best course of action would be to
terminate your sessions at a set interval rather then letting them time
out on their own."
Huh??? Isn't that how sessions are supposed to work? You set session
variables, and they will timeout in a set period of time. That's how
it works in ASP. That's how it works in ColdFusion. Is that not the
case in PHP?

It sounds to me like a bogus answer, so I'd like some "expert"
opinions.

Thanks in advance for your help!

- Bryan

Jul 17 '05 #1
5 1718
*** br***@chameleon-systems.com wrote/escribió (13 Jan 2005 08:46:31
-0800):
Huh??? Isn't that how sessions are supposed to work? You set session
variables, and they will timeout in a set period of time. That's how
it works in ASP. That's how it works in ColdFusion. Is that not the
case in PHP?


I suppose you use the built-in session handler, don't you? Write a script
with <? phpinfo() ?> as its only content and find the "session" table.
Check the session.save_handler directive. Is the server configured to store
sessions in a MySQL database?

As about zombie MySQL processes, MySQL connections are closed when the
script ends. The only exception are persistent connections (unless PHP is
configured not to allow them). Keeping a session open just means the data
will be stored for more time, which should not be an issue for any database
engine.

--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #2
br***@chameleon-systems.com wrote:
<snip>
This week there was a problem with the site not having access to the
MySQL database the site uses. The hosting company sent me this message as an explanation for the problem:

"the culprit seems to be the way that you are handing sessions on the
GPR_intro.php page. The sessions are not being terminated in a timely
manner which is causing a back log of processes on the MySQL service
and is causing it to fail. The best course of action would be to
terminate your sessions at a set interval rather then letting them time out on their own."
Hmm... I don't think, your setup is complex to handle custom DB
based session handler. Perhaps there might be some issue with
persistent connection as someone suggested.

But, I also have the opinion that they wrongly mean session file
locking which can be fixed with proper usage of
<http://in2.php.net/session_write_close>
Huh??? Isn't that how sessions are supposed to work? You set session variables, and they will timeout in a set period of time.


That's configurable (session.gc_maxlifetime). Looking at the manual
might be of more help <http://in2.php.net/session>

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #3
Álvaro,

Thanks for the response. I ran the phpinfo command like you suggested,
and here's what I got:

Directive Local Value Master Value
session.save_handler files files

That seems to indicate to me that MySQL isn't involved in the equation
at all, right?

Bryan

Alvaro G Vicario wrote:
*** br***@chameleon-systems.com wrote/escribió (13 Jan 2005 08:46:31
-0800):
Huh??? Isn't that how sessions are supposed to work? You set session variables, and they will timeout in a set period of time. That's how it works in ASP. That's how it works in ColdFusion. Is that not the case in PHP?
I suppose you use the built-in session handler, don't you? Write a

script with <? phpinfo() ?> as its only content and find the "session" table. Check the session.save_handler directive. Is the server configured to store sessions in a MySQL database?

As about zombie MySQL processes, MySQL connections are closed when the script ends. The only exception are persistent connections (unless PHP is configured not to allow them). Keeping a session open just means the data will be stored for more time, which should not be an issue for any database engine.

--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--


Jul 17 '05 #4
*** br***@chameleon-systems.com wrote/escribió (13 Jan 2005 12:53:08
-0800):
Directive Local Value Master Value
session.save_handler files files

That seems to indicate to me that MySQL isn't involved in the equation
at all, right?


Certainly: it's using the default handler, that's it, session data is
stored into files.

In any case, check GPR_intro.php in case there's actually something wrong
with your code.
--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #5
Thanks for the help, Álvaro. It just didn't seem to make sense to me
that the sessions would affect the database. The memory, or file space
on the web server I could understand, but not he database.

I'll double check my code just to be sure, but it's pretty straight
forward. When a person logs in, I do a session_start() at the top of
the page, then $_SESSION["userid"] = $sUserID further down in the code.

On the protected pages, I also do a session_start(), then I do a
isset($_SESSION["userid"]) check to see if the person is logged in or
not.

That's all there is to it.

Bryan

Alvaro G Vicario wrote:

Certainly: it's using the default handler, that's it, session data is
stored into files.

In any case, check GPR_intro.php in case there's actually something wrong with your code.
--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--


Jul 17 '05 #6

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

Similar topics

13
by: jing_li | last post by:
Hi, you all, I am a newbee for php and I need your help. One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location...
0
by: Gleep | last post by:
Hey PHP Gurus, I have some complex scripts that work fine. I have a system where sessions are validated on every page of my application to keep them secure. Everything runs fine when I test and...
1
by: Rob | last post by:
I have an ASP.NET application that uses forms-based authentication. A user wishes to be able to run multiple sessions of this application simultaneously from the user's client machine. The...
3
by: Miguel | last post by:
Hi all friends: It's said that Sessions objects in ASP 3.0 with IIS 5.0 occupy certain memory of the machine which take to take care about use a lot of Sessions objects in the ASPs pages of the...
4
by: Edgardo Sepulveda | last post by:
Hi, one question, is there a limit on the numbers of sessions that a client can have? i dont know why but suddently, as i handle a lot of the user information with sessions, and also have added a...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory†exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
13
by: Simon Dean | last post by:
And while Im at it... should I be using PHP's built in sessions, or use my own functions that I've chobbled together from various sources and takes advantage of also validating IP Addresses??? I...
1
by: Evan Nelson | last post by:
We are running our website on 3 W2K servers using classic ASP and IIS 5.0. Because the servers are load balanced we don't use the ASP Session object instead we store session type information to the...
22
by: magic_hat60622 | last post by:
Hi all. I've got an app that dumps a user id into a session after successful login. the login page is http://www.mydomain.com/login.php. If the user visits pages on my site without the www (i.e.,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.