[PHP] Cookie
Hi, I use : apache 1.3.26, php 4.2.3, postgresql 7.2 (under solaris 7). I attempt to modify my old sources which run with the previous versions and I meet a problem with the cookie. I read that we can see the contents of a cookie with 2 methods : echo $testcookie echo $_COOKIE["testcookie"] For me, only the second method runs. An idea ? In advance, thanks mb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookie
Thanks for your response. The doc isn't explicit when it explains this two methods and don't focus on the register globals function for the first method. So I use the second method only. Thanks mb Bob Irwin wrote: > > I'm pretty sure this is a global variables problem. > > There is an option in your ini.php file that refers to 'global variables' > You need to set this on, otherwise reference to them with the absolute > variable name. > > Best Regards > Bob Irwin > Server Admin & Web Programmer > Planet Netcom > - Original Message - > From: "Max Buvry" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, October 02, 2002 2:37 AM > Subject: [PHP] Cookie > > > > > > > Hi, > > > > I use : apache 1.3.26, php 4.2.3, postgresql 7.2 (under solaris 7). > > > > I attempt to modify my old sources which run with the previous versions > > and I meet a problem with the cookie. > > > > I read that we can see the contents of a cookie with 2 methods : > > > > echo $testcookie > > echo $_COOKIE["testcookie"] > > > > For me, only the second method runs. > > > > An idea ? > > > > In advance, thanks > > > > mb > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > Scanned by PeNiCillin http://safe-t-net.pnc.com.au/ > > > > Scanned by PeNiCillin http://safe-t-net.pnc.com.au/ > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Erase the cookie sessions
Hi, I wish test the session. I use php 4.2.3 et session.auto_start is 1. My first example is : Session example "; echo "hello ! : $cpt times"; session_unset(); session_destroy(); } ?> I don't find the solution to use setcookie ; I try the two instructions above (the script is correct without the "else"). An idea ? In advance, thanks. mb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Erase the cookie sessions
Marek Kilimajer wrote: > > You miss closing } > Thanks, but that's a copy-paste error and that's not my problem really. mb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Erase the cookie sessions
Max Buvry wrote: > > Marek Kilimajer wrote: > > > > You miss closing } > > > > Thanks, but that's a copy-paste error and that's not my problem really. > > mb Solved : my solution for information (before test with url !) 5 ) { $cook_param= session_get_cookie_params(); $life_time= $cook_param['lifetime']; $path= $cook_param['path']; setcookie(session_name(),"",$life_time,$path); echo "Session and cookie"; echo "session change"; echo "hello ! : it's ".$_SESSION['count']."times and the last"; $_SESSION= array();//session_unset(); session_destroy(); echo ""; } else { echo "Session and cookie"; $cpt = $_SESSION['count']; echo "hello ! : it's ".$_SESSION['count']."times"; echo " Information :"; echo "name = ".session_name().""; echo "id = ".session_id().""; echo ""; } ?> The problem was setcookie execution after the header sending. mb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session and URL
I meet a probleme with the session. My example considers 2 scripts : - the first script (test_session_url.php) opens a session (session.auto_start=1 in php.ini), defines a counter, prints some information and an hypertext to execute the second script which has session id as parameter Session and URL"; echo "hello ! : it's ".$_SESSION['count']." visit"; echo " Information :"; echo "--->name = ".session_name().""; echo "--->id = ".session_id().""; echo "next page"; echo ""; ?> - the second script (nextpage_session_url.php) validates the parameter (set, empty, value), add one to the counter and then check the value of the counter. It makes the same thing 5 times by printing an hypertext with itself and after, it prints an new hypertext to come back to the first script by beginning a NEW SESSION. Session and URL"; echo "parameter error"; echo ""; exit; } $id= $_GET[session_name()]; if ( $id != session_id() ) { echo "Session and URL"; echo "value of session id error : "; echo "parameter : $id and current session_id :".session_id()."--"; echo ""; } else { $_SESSION['count']++; if ( $_SESSION['count'] > 5 ) { $_SESSION= array(); session_destroy(); session_start(); // problem is the same with or without this instruction include("test_session_url.php"); } else { echo "Session and URL"; $cpt = $_SESSION['count']; echo "hello ! : it's ".$_SESSION['count']." visit"; echo " Information :"; echo "--->name = ".session_name().""; echo "--->id = ".session_id().""; echo "next page"; echo ""; } } ?> Now my problem : NEVER a new session (with a new ident) is created. However I execute $_SESSION= array(); and session_destroy(); I use php 4.2.3 and apache 1.3.26 For testing, I configurate my browser to refuse the cookies (but the problem is the same when I accept the cookies). Perhaps something to change in php.ini ? In advance thanks. mb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions: Trigger a new one, Expire an old one
Hi, I use php 4.2.3 with session.auto_start = 1 in php.ini What I use with URL session : $_SESSION= array(); unset($_GET[session_name()]); session_destroy(); Header("Location: next_script.php"); with cookie session : $cook_param= session_get_cookie_params(); $life_time= $cook_param['lifetime']; $path= $cook_param['path']; setcookie(session_name(),"",$life_time,$path); $_SESSION= array(); session_destroy(); mb Jonathan Sharp wrote: > > Ok, here is my solution: > > I wanted this to be as self contained as possible: > > function clean() > { > /* get name of session & find session id */ > $name = ini_get('session.name'); > $sessid = ( !$_COOKIE[$name] ? > ( !$_GET[$name] ? > ( !$_POST[$name] ? false : $_POST[$name] ) : > $_GET[$name] ) : > $_COOKIE[$name] ); > > /* run query now to see if sesion is expired, if yes */ > unset( $_COOKIE[$name] ); > unset( $_GET[$name] ); > unset( $_POST[$name] ); > unset( $_REQUEST[$name] ); > } > > clean(); > session_start(); > > Since _COOKIE/etc needs to be UNSET before session_start is called and > re-calling session_start does sqat, the above code (not all of it but > general idea) 'finds' the session id (session_id() has no effect until > session_start is called) and tests to see if it's expired, if so, it > 'kills' all possible locations for session_start() to find an id. > > *simple*... (or something like that) > > -js > > Chris Shiflett wrote: > > Yeah, John hinted at the answer there. > > > > You just need to make the session ID go away prior to starting the > > session . Just unset it or set it to the empty string or whatever you > > want to do. > > > > It is probably either $_COOKIE["PHPSESSID"] or $_GET["PHPSESSID"]. > > > > Chris > > > > John W. Holmes wrote: > > > >>> "Simple" question. If a users session expires or has timed out, how do > >>> > >>> I 'force' php to generate a new sessionId? > >>> > >> > >> Session_start() ?? > >> > >> If there isn't a session id present, it'll create one. > >> > >> ---John Holmes... > >> > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Postgres-Transaction-user_ignore_abort-Connection stop by the client
Hi, I use Postgresql 7.2.2 + php 4.2.3 and I meet a problem with transaction and connections interruption. The application is the famous example of the bank accounts and the money transfers. I consider a table named "DEAL" where each transaction is saved. Each tuple has an id number as key. When a tuple is added, the maximum value of id is computed, and increased by one to determinate the key of the next tuple. My script php follows this steps : ignore_user_abort(0|1) Compute the key -> v BEGIN WORK UPDATE the first bank account with v (credit) sleep(300) UPDATE the second bank account with v+1 (debit) COMMIT WORK While the sleep, the client may use the STOP button on his browser and stop the connection. I tried to execute exhaustive tests : ignore_user_abort(0) or ignore_user_abort(1), with or without transaction, with or without rollback. For these tests, I follow two steps : 1/ the client execute the first request but stops the connection while the sleep instruction. 2/ with pgaccess, I read the content of DEAL 3/ the client executes a new request without interruption 4/ the result is displayed on the browser and checked with pgaccess TEST 1 request 1 * ignore_user_abort(0) Compute the key -> v=10 BEGIN WORK UPDATE the first bank account with v as key (credit) sleep(300)--> INTERRUPT UPDATE the second bank account with v+1 as key (debit) COMMIT WORK Result : nothing new in the database (with pgaccess) request 2 * ignore_user_abort(0) Compute the key -> v=10 BEGIN WORK UPDATE the first bank account with v (credit) UPDATE the second bank account with v+1 (debit) COMMIT WORK Result : the request 1 is executed now ! and while the key (v=10) is the same, the request 2 fails. Problem : why the whole first request is taking into account now ? TEST 2 The same by removing BEGIN and COMMIT. The first request : only the first update (before the stop) is executed The second request is executed correctly. Problem : ignore_user_abort is called with 0, so why the execution of the script for the first request doesn't continue ? TEST 3 and 4 The tests 3 and 4 reproduce the test 1 and 2 by using ignore_user_abort(1). The results are absolutely the same ! TEST 5 and 6 The tests 5 and 6 reproduce the test 1 and 2 by using ROLLBACK if ( connection_aborted() ) { ROLLBACK WORK; exit } is added after the sleep. The results are absolutely the same again ! I find the results very strange, isn't it. In advance, thanks for your help. mb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php