RE: [PHP-DB] [PHP]: session problem
On 24 June 2004 16:44, H. J. Wils wrote: > this is the code, but this code works on my hosting provider but not > on my own server. I think i have to change settings in php.ini but > dont know which... > first page: > > session_start(); > > include "connect.php"; > include "functions.php"; > > $user= $_GET["email"]; > $ww = $_GET["ww"]; > > $check_user_query = "select id,email, password from user where > email='$user' and password='$ww'"; > $check_user_res = mysql_query($check_user_query) or > die(mysql_error().": $check_user_query"); > > if (mysql_num_rows($check_user_res) == 1){ > //user is ingelogd > >$userdata = > mysql_fetch_array($check_user_res); >$sid=session_id(); >$uid=$userdata["id"]; >$_SESSION['logged_in'] = true; >$_SESSION['sid'] = $sid; >$_SESSION['user'] = $uid; > >$dt = date("Y-m-d H:i:s"); > > header("location: user.php?action=0"); > }else{ > header("location: user.php?action=9"); > } Redirecting like this will not pass the session id in the URL if that is necessary, which it would be if cookies are not being used. Since you say it works for you from your provider's system but not your local one, this suggests that your provider has session.use_cookies turned on, but you have it turned off. If this is so, you can solve your immediate problem by turning that option on in your php.ini, but the redirects will still not work correctly for anyone who has cookies turned off in their browser. If you are bothered about this, you need to make use of the handy-dandy SID constant that PHP helpfully provides, thusly: header("Location: user.php?action=0&".SID); or, if you're a tidy-URL geek, something like: header("Location: user.php?action=0".(SID?"&".SID:"")); (BTW, notice the correct spelling of the "Location" header, with a capital L; and, yes, others are right when they say it should be a full absolute URL. These things have been known to matter to some browsers, so it's best to make a habit of getting them right!) Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] [PHP]: session problem
OK then, couple more questions. 1. What is user.php? Is it the code you posted under "second page"? 2. Also, on your first page, are you sure that your $check_user_res = mysql_query($check_user_query) or die(mysql_error().": $check_user_query"); query is firing properly? If it isn't then your session variables are not being assigned. I know you said it's working on your host's server, but is there maybe a small difference between your local and remote databases that might cause the query to fail when executed locally? Admittedly, I'm poking around in the dark here. Rich Hutchins, MCIW Sr. Technical Publications Analyst Getinge USA 1777 E. Henrietta Rd. Rochester NY 14623 585-272-5072 www.getingeusa.com > -Original Message- > From: H. J. Wils [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 24, 2004 11:44 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: Re: [PHP-DB] [PHP]: session problem > > > this is the code, but this code works on my hosting provider > but not on my > own server. I think i have to change settings in php.ini but > dont know > which... > first page: > > session_start(); > > include "connect.php"; > include "functions.php"; > > $user= $_GET["email"]; > $ww = $_GET["ww"]; > > $check_user_query = "select id,email, password from > user where > email='$user' and password='$ww'"; > $check_user_res = mysql_query($check_user_query) or > die(mysql_error().": $check_user_query"); > > if (mysql_num_rows($check_user_res) == 1){ > //user is ingelogd > >$userdata = > mysql_fetch_array($check_user_res); >$sid=session_id(); >$uid=$userdata["id"]; >$_SESSION['logged_in'] = true; >$_SESSION['sid'] = $sid; >$_SESSION['user'] = $uid; > >$dt = date("Y-m-d H:i:s"); > > header("location: user.php?action=0"); > }else{ > header("location: user.php?action=9"); > } > > > second page: > > > session_start(); > > if ( isset($_SESSION['logged_in'])){ > > echo "Welcome..."; > > }else{ > header("location: user.php?action=9"); > } > ?> > > _ > Hotmail en Messenger on the move > http://www.msn.nl/communicatie/smsdiensten/hotmailsmsv2/ > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PHP]: session problem
this is the output: Array ( ) very empty ;) From: "Matt Matijevich" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> Subject: Re: [PHP-DB] [PHP]: session problem Date: Thu, 24 Jun 2004 10:50:01 -0500 MIME-Version: 1.0 Received: from stimpy.alliancetechnologies.net ([63.86.10.3]) by mc3-f33.hotmail.com with Microsoft SMTPSVC(5.0.2195.6824); Thu, 24 Jun 2004 08:51:21 -0700 Received: from NW0101DSM.ALLIANCETECHNOLOGIES.NET (nw0101dsm.alliancetechnologies.net [192.168.1.28])by stimpy.alliancetechnologies.net (8.11.6/8.11.6) with ESMTP id i5OFoID27643for <[EMAIL PROTECTED]>; Thu, 24 Jun 2004 10:50:18 -0500 Received: from ITGRP-MTA by NW0101DSM.ALLIANCETECHNOLOGIES.NETwith Novell_GroupWise; Thu, 24 Jun 2004 10:50:18 -0500 X-Message-Info: JGTYoYF78jGdnwFcx9O+QzEKQtzYKOwT Message-Id: <[EMAIL PROTECTED]> X-Mailer: Novell GroupWise Internet Agent 6.5.2 Beta Return-Path: [EMAIL PROTECTED] X-OriginalArrivalTime: 24 Jun 2004 15:51:22.0116 (UTC) FILETIME=[18D3EC40:01C45A03] do you get any output on the second page if you do this? session_start(); print ''; print_r($_SESSION); print ''; if ( isset($_SESSION['logged_in'])){ echo "Welcome..."; }else{ header("location: user.php?action=9"); } ?> _ Play online games with your friends with MSN Messenger http://messenger.msn.nl/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PHP]: session problem
What are you setting $_SESSION['sid'] to? > i do ($_SESSION['sid']), but the variables remain empty... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] [PHP]: session problem
indeed... From: "Hutchins, Richard" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] [PHP]: session problem Date: Thu, 24 Jun 2004 11:52:38 -0400 MIME-Version: 1.0 Received: from pb1.pair.com ([216.92.131.4]) by mc6-f23.hotmail.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 24 Jun 2004 08:53:06 -0700 Received: (qmail 46847 invoked by uid 1010); 24 Jun 2004 15:52:42 - Received: (qmail 46808 invoked by uid 1010); 24 Jun 2004 15:52:42 - X-Message-Info: JGTYoYF78jFRl5xFT3FYrNMzPyW4jY3K Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm Precedence: bulk list-help: <mailto:[EMAIL PROTECTED]> list-unsubscribe: <mailto:[EMAIL PROTECTED]> list-post: <mailto:[EMAIL PROTECTED]> Delivered-To: mailing list [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> X-Mailer: Internet Mail Service (5.5.2657.72) Return-Path: [EMAIL PROTECTED] X-OriginalArrivalTime: 24 Jun 2004 15:53:08.0025 (UTC) FILETIME=[57F45A90:01C45A03] So, on your second page you NEVER see the "Welcome..." get echoed out? It always forwards you to the user.php page? > -Original Message- > From: H. J. Wils [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 24, 2004 11:44 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: Re: [PHP-DB] [PHP]: session problem > > > this is the code, but this code works on my hosting provider > but not on my > own server. I think i have to change settings in php.ini but > dont know > which... > first page: > > session_start(); > > include "connect.php"; > include "functions.php"; > >$user= $_GET["email"]; >$ww = $_GET["ww"]; > >$check_user_query = "select id,email, password from > user where > email='$user' and password='$ww'"; >$check_user_res = mysql_query($check_user_query) or > die(mysql_error().": $check_user_query"); > >if (mysql_num_rows($check_user_res) == 1){ > //user is ingelogd > > $userdata = > mysql_fetch_array($check_user_res); > $sid=session_id(); > $uid=$userdata["id"]; > $_SESSION['logged_in'] = true; > $_SESSION['sid'] = $sid; > $_SESSION['user'] = $uid; > > $dt = date("Y-m-d H:i:s"); > > header("location: user.php?action=0"); >}else{ > header("location: user.php?action=9"); >} > > > second page: > > > session_start(); > > if ( isset($_SESSION['logged_in'])){ > > echo "Welcome..."; > > }else{ > header("location: user.php?action=9"); > } > ?> > > _ > Hotmail en Messenger on the move > http://www.msn.nl/communicatie/smsdiensten/hotmailsmsv2/ > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Talk with your online friends with MSN Messenger http://messenger.msn.nl/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PHP]: session problem
On Thursday 24 June 2004 23:43, H. J. Wils wrote: [snip] >$_SESSION['logged_in'] = true; >$_SESSION['sid'] = $sid; >$_SESSION['user'] = $uid; > >$dt = date("Y-m-d H:i:s"); You should always session_write_close() before you redirect. > header("location: user.php?action=0"); You should be using an absolute URI rather than a relative one. And just to be safe always have an exit() right after your redirect header(s). -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* It is a hard matter, my fellow citizens, to argue with the belly, since it has no ears. -- Marcus Porcius Cato */ -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Fun Facts, #14: In table tennis, whoever gets 21 points first wins. That's how it once was in baseball -- whoever got 21 runs first won. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] [PHP]: session problem
So, on your second page you NEVER see the "Welcome..." get echoed out? It always forwards you to the user.php page? > -Original Message- > From: H. J. Wils [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 24, 2004 11:44 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: Re: [PHP-DB] [PHP]: session problem > > > this is the code, but this code works on my hosting provider > but not on my > own server. I think i have to change settings in php.ini but > dont know > which... > first page: > > session_start(); > > include "connect.php"; > include "functions.php"; > > $user= $_GET["email"]; > $ww = $_GET["ww"]; > > $check_user_query = "select id,email, password from > user where > email='$user' and password='$ww'"; > $check_user_res = mysql_query($check_user_query) or > die(mysql_error().": $check_user_query"); > > if (mysql_num_rows($check_user_res) == 1){ > //user is ingelogd > >$userdata = > mysql_fetch_array($check_user_res); >$sid=session_id(); >$uid=$userdata["id"]; >$_SESSION['logged_in'] = true; >$_SESSION['sid'] = $sid; >$_SESSION['user'] = $uid; > >$dt = date("Y-m-d H:i:s"); > > header("location: user.php?action=0"); > }else{ > header("location: user.php?action=9"); > } > > > second page: > > > session_start(); > > if ( isset($_SESSION['logged_in'])){ > > echo "Welcome..."; > > }else{ > header("location: user.php?action=9"); > } > ?> > > _ > Hotmail en Messenger on the move > http://www.msn.nl/communicatie/smsdiensten/hotmailsmsv2/ > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PHP]: session problem
do you get any output on the second page if you do this? '; print_r($_SESSION); print ''; if ( isset($_SESSION['logged_in'])){ echo "Welcome..."; }else{ header("location: user.php?action=9"); } ?> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PHP]: session problem
Are you getting any errors displayed? The php.ini file has to have a directory specified for the session temp variables. > I want to use sessions to check wether a user is logged in or not. > Therefore,I use session_start and session_register. When I registere the > values on the same page, they all seem to work. But when I ask the value > of > a registered session variable on another page, it is empty?!?! Does anyone > know how this comes? i am using session_start() at every page.. > > i believe it must be in my php.ini setting because on my hosting provider > it > does work all correctly.. can anyone helpme? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PHP]: session problem
this is the code, but this code works on my hosting provider but not on my own server. I think i have to change settings in php.ini but dont know which... first page: session_start(); include "connect.php"; include "functions.php"; $user= $_GET["email"]; $ww = $_GET["ww"]; $check_user_query = "select id,email, password from user where email='$user' and password='$ww'"; $check_user_res = mysql_query($check_user_query) or die(mysql_error().": $check_user_query"); if (mysql_num_rows($check_user_res) == 1){ //user is ingelogd $userdata = mysql_fetch_array($check_user_res); $sid=session_id(); $uid=$userdata["id"]; $_SESSION['logged_in'] = true; $_SESSION['sid'] = $sid; $_SESSION['user'] = $uid; $dt = date("Y-m-d H:i:s"); header("location: user.php?action=0"); }else{ header("location: user.php?action=9"); } second page: session_start(); if ( isset($_SESSION['logged_in'])){ echo "Welcome..."; }else{ header("location: user.php?action=9"); } ?> _ Hotmail en Messenger on the move http://www.msn.nl/communicatie/smsdiensten/hotmailsmsv2/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PHP]: session problem
[snip] i do ($_SESSION['sid']), but the variables remain empty... [/snip] If you are using the array forget about session_register. http://www.php.net/session_register Could you post a little code? That will make this easier to solve. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PHP]: session problem
i do ($_SESSION['sid']), but the variables remain empty... From: "Matt Matijevich" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> Subject: Re: [PHP-DB] [PHP]: session problem Date: Thu, 24 Jun 2004 09:58:15 -0500 MIME-Version: 1.0 Received: from pb1.pair.com ([216.92.131.4]) by mc5-f25.hotmail.com with Microsoft SMTPSVC(5.0.2195.6824); Thu, 24 Jun 2004 07:58:51 -0700 Received: (qmail 11455 invoked by uid 1010); 24 Jun 2004 14:58:34 - Received: (qmail 11442 invoked by uid 1010); 24 Jun 2004 14:58:34 - X-Message-Info: JGTYoYF78jFwyYeDNPzY/BffcKW489ih Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm Precedence: bulk list-help: <mailto:[EMAIL PROTECTED]> list-unsubscribe: <mailto:[EMAIL PROTECTED]> list-post: <mailto:[EMAIL PROTECTED]> Delivered-To: mailing list [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Message-Id: <[EMAIL PROTECTED]> X-Mailer: Novell GroupWise Internet Agent 6.5.2 Beta Return-Path: [EMAIL PROTECTED] X-OriginalArrivalTime: 24 Jun 2004 14:58:51.0428 (UTC) FILETIME=[C2DF1640:01C459FB] [snip] But when I ask the value of a registered session variable on another page, it is empty?!?! Does anyone know how this comes? i am using session_start() at every page.. [/snip] try the $_SESSION array for starage of session variables. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PHP]: session problem
[snip] But when I ask the value of a registered session variable on another page, it is empty?!?! Does anyone know how this comes? i am using session_start() at every page.. [/snip] try the $_SESSION array for starage of session variables. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] [PHP]: session problem
I want to use sessions to check wether a user is logged in or not. Therefore,I use session_start and session_register. When I registere the values on the same page, they all seem to work. But when I ask the value of a registered session variable on another page, it is empty?!?! Does anyone know how this comes? i am using session_start() at every page.. i believe it must be in my php.ini setting because on my hosting provider it does work all correctly.. can anyone helpme? _ Play online games with your friends with MSN Messenger http://messenger.msn.nl/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP session problems
I have been having trouble with PHP sessions, the session variables are not able to be called through the script. If have commented the area at the bottome where the session variable is NULL when var dump is called to check it (about 20 lines from the bottom... depending on if the text is wrapping or not) here is the actual code == include "library/include/header.php" ; include "library/include/database.php" ; /* Include a header file and a database connections/functions file */ if ( ( !isset ( $HTTP_COOKIE_VARS["username"] ) ) && ( !isset ( $proceed ) ) && ( !isset ( $submit ) ) ) { /* The Cookie is not set, so load the page as if it is the first time */ ?> While( $row = mysql_fetch_array($result) ) { ?> "> } ?> } elseif( ( !isset ( $HTTP_COOKIE_VARS["username"] ) ) && ( !isset ( $submit ) ) && ( isset ( $proceed ) ) ) { /* The User is now attempting to register */ ?> session_register('valid_user'); $_SESSION["valid_user"] = $staffid; $_SESSION['name'] = $row["1"]; ?> Welcome What is your National Insurance Number Choose a password Enter it again } elseif( ( !isset ( $HTTP_COOKIE_VARS["username"] ) ) && ( isset ( $submit ) ) ) { /* information for registration has been entered, lets check if it is valid */ $_SESSION['valid_user'] = $staffid ; $ni = $HTTP_POST_VARS["ni1"] . $HTTP_POST_VARS["ni2"] . $HTTP_POST_VARS["ni3"] . $HTTP_POST_VARS["ni4"] . $HTTP_POST_VARS["ni5"] ; $query = " SELECT * FROM Staff WHERE StaffId = '$staffid'"; $result = mysql_query($query) or die( mysql_error () ); $row = mysql_fetch_array($result); /* HERE THE SESSION VARIABLE HAS NO VALUE... WHEN I CALL VARDUMP IT IS NULL */ var_dump($_SESSION["valid_user"]); echo $ni ; echo $staffid; if( $ni == $row["4"]){ echo "ni check successful"; if( $pass1 != $pass2 ){ echo "Your Passwords are not the same" ; } else{ $query = "INSERT INTO Staff WHERE StaffId = '$staffid' password values ('$pass1')"; if($result=mysql_query($query)){ echo "your password has been set, Continue to the site"; } } } } include "library/include/footer.php" ; ?> _ Stay in touch with MSN Messenger http://messenger.msn.co.uk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php session
> -Original Message- > From: Chris Barnes [mailto:[EMAIL PROTECTED]] > Sent: 02 December 2002 02:14 > > On Mon, 2002-12-02 at 02:43, John W. Holmes wrote: > > > > No, it shouldn't. > > > > So, the links are correct on one page, and they disappear > on the second > > page? Is there a reason you're passing the SID in the URL > and not using > > cookies? > > > > Hmmm, found this in the manual. Maybe it applies? > > > > --- > > The constant SID can also be used to retrieve the current name and > > session id as a string suitable for adding to URLs. Note that SID is > > only defined if the client didn't sent the right cookie. See also > > Session handling. > > --- > > > > You may have to call session_id() with the passed value of > > $_GET['PHPSESSID'] so that PHP knows what session to restart. > > > > ---John Holmes... > > > > The reason I'm not using cookies is because i don't really know enough > about them yet (i don't really know enough about sessions > either :p). Do > you think it would be better for me to generate my own unique > number and > set that in the cookie? Will i have to keep calling > SetCookie() on every > page? > > One thing i should have mentioned in my previous email, even though it > isn't that relevant i don't think, is that if i omit the SID constant > from the URL string then PHP automatically appends the SID to the URL > its self, but again it disappears after a link has been clicked. All of the evidence you have presented, and especially this, suggests that PHP is automatically using cookies to store the SID. When this is the case, you see the SID on the first page served by PHP (because it hasn't set the cookie yet!), but on all subsequent pages it disappears and the SID is propagated using a cookie. You *can* configure this to work differently, but, speaking purely personally, I don't see the point. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php session
On Mon, 2002-12-02 at 02:43, John W. Holmes wrote: > > No, it shouldn't. > > So, the links are correct on one page, and they disappear on the second > page? Is there a reason you're passing the SID in the URL and not using > cookies? > > Hmmm, found this in the manual. Maybe it applies? > > --- > The constant SID can also be used to retrieve the current name and > session id as a string suitable for adding to URLs. Note that SID is > only defined if the client didn't sent the right cookie. See also > Session handling. > --- > > You may have to call session_id() with the passed value of > $_GET['PHPSESSID'] so that PHP knows what session to restart. > > ---John Holmes... > The reason I'm not using cookies is because i don't really know enough about them yet (i don't really know enough about sessions either :p). Do you think it would be better for me to generate my own unique number and set that in the cookie? Will i have to keep calling SetCookie() on every page? One thing i should have mentioned in my previous email, even though it isn't that relevant i don't think, is that if i omit the SID constant from the URL string then PHP automatically appends the SID to the URL its self, but again it disappears after a link has been clicked. signature.asc Description: This is a digitally signed message part
RE: [PHP-DB] php session
> I'm having a little trouble getting sessions to work properly with php. > I have put session_start(); on all pages before any data is printed. The > session will start on the first loading of the page but after a link is > clicked the session seems to die i have no idea why. > > for the links on the pages i have included the SID constant like so: > Link but after a link > is clicked the links them appear to lose the reference to the SID > constant so instead of looking like > > Link > > the session_start(); isn't right at the start of the pages, its a few > lines after but none of the lines before session_start(); print any > data, they only store data in variables...does that matter?? No, it shouldn't. So, the links are correct on one page, and they disappear on the second page? Is there a reason you're passing the SID in the URL and not using cookies? Hmmm, found this in the manual. Maybe it applies? --- The constant SID can also be used to retrieve the current name and session id as a string suitable for adding to URLs. Note that SID is only defined if the client didn't sent the right cookie. See also Session handling. --- You may have to call session_id() with the passed value of $_GET['PHPSESSID'] so that PHP knows what session to restart. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] php session
hi people, I'm having a little trouble getting sessions to work properly with php. I have put session_start(); on all pages before any data is printed. The session will start on the first loading of the page but after a link is clicked the session seems to die i have no idea why. for the links on the pages i have included the SID constant like so: Link but after a link is clicked the links them appear to lose the reference to the SID constant so instead of looking like Link the session_start(); isn't right at the start of the pages, its a few lines after but none of the lines before session_start(); print any data, they only store data in variables...does that matter?? I'm completely stumped trying to get this to work properly. can anyone offer any suggestions? Thanks heaps. signature.asc Description: This is a digitally signed message part
Re: [PHP-DB] PHP Session End.
There is no way to know if the user has left the website. About all you can do is save a timestamp in the database for every recordable action the user performs then if no actions take place for say 10 minutes that user is said to be 'logged out' and you delete the database row and deallocate any PIN's they may have accumulated. But let me ask you a question... Why exactly does the system allocate a PIN when the user adds it to their cart? Wouldn't you solve your problem by simply waiting until the transaction is complete? -Kevin - Original Message - From: "Hayan Al Mamoun" <[EMAIL PROTECTED]> To: "PHPList (E-mail)" <[EMAIL PROTECTED]> Sent: Monday, June 03, 2002 1:49 AM Subject: [PHP-DB] PHP Session End. > Dear ALL, > > I'm programming a web site that has a small shopping cart to sell virtual > information, I must allocate the information I'm selling (Phone Card PIN > Codes) and block it from others, once a user adds it to his cart, and on the > other hand, I must set it free (DeAllocate it) when the user leaves the site > without checking out. I'm using session to figure out the users, but I donno > how to sense when the user has left the site, and his session is closed > (automatically). > > Any Body Can Help?? > Thanx in Advanced > bst rgds > Hayan > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP Session End.
Dear ALL, I'm programming a web site that has a small shopping cart to sell virtual information, I must allocate the information I'm selling (Phone Card PIN Codes) and block it from others, once a user adds it to his cart, and on the other hand, I must set it free (DeAllocate it) when the user leaves the site without checking out. I'm using session to figure out the users, but I donno how to sense when the user has left the site, and his session is closed (automatically). Any Body Can Help?? Thanx in Advanced bst rgds Hayan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php