Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL driven & PHP sessions Q

Status
Not open for further replies.

alfalf

Programmer
Joined
Mar 6, 2003
Messages
155
Location
BA
Hello all.

I have an problem:

I run (temporarily) PHP 4.3.6 with MySQL 4.1.0 database driven sessions on IIS (XP). My handler used to store/retrieve sess data (stored in php.ini) is:
session.save_handler = user

I have an table in wich I store my sessions (id, variables,...).

And thing works just fine - when I want my session to begin or continue I use sess_init(...) function from phpSecureSessions.inc file I have here.

MY PROBLEM IS IN FOLLOWING:
How to properely check if session is registered? Cause, if I have registered one, I would like my user (or visitor) to continue with session, but if session is not registered I want to start a new one for that user (I store users IP address and session variables along with standard session data).

I have this code (wich I changed, for example instead session_is_registered(...) I tried also to use if (!isset(session_id())){...} with no desirable results):

include ('phpSecureSessions.inc');
if (session_is_registered('visitor')){
sess_init('localhost','sessions','root','','1');
}
else
{
sess_init('localhost','sessions','root','','1');
$_SESSION['user']='visitor';
$_SESSION['datum']=date("Y M d.");
$_SESSION['vrijeme']=date("G:i:s");
$_SESSION['timezone']=date("T");
}


but I receive this result:
session id is unchanged for same user (comming from same IP) but session variables are changed, no matter that session is only continuing. What could be the solution for this?

Any idea?

PS
If neccesary, I'll post phpSecureSessions.inc file I have here, but I don't think the problem there.

Thanks!
 
I did the same thing -- using MySQL as the data backend for PHP's sessions. My code is available in faq434-2037.

I just let PHP's session-handling mechanism handle decisions as to the issue or reuse of session index cookies.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks slepnir214.
How do you do that? :-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top