[PHP] Re: Session help please?

2004-04-02 Thread Justin Patrin
Paul wrote:

Probably a stupid question.

I figured I could do something like $_SESSION['test'] = 5 and refer to $test
on other pages however I cannot. The reason I thought I could do this is
because I can do $_SESSION['test'] = $_POST['test'] and be able to refer to
just $test on other pages.
Is the correct way to do this to make sure that I have somewhere
session_register['test']
Thanks!
It is true that you should be able to use $test to access the session 
var in other pages, but only if you have register_globals on and you 
have called session_start().

$_SESSION['var'] = 1;
is the same as
$var = 1;
session_register('var');
However, it's never a good idea to rely on globals because:
  1) The variable could come from the session, POST, or GET and you 
don't know which one it comes from. Sure, you know the order of 
precedence (you can even set it yourself in the php.ini), but you still 
don't know which one was used.
  2) Within functions, you don't have direct access to global 
variables. You can use global $var; but that's *VERY* prone to errors. 
You can use $GLOBALS['var'] but that's nearly as much typing as 
$_SESSION['var'] and is far less reliable and secure.

My suggestion is to turn off register_globals (as many others will tell 
you) and use $_POST, $_GET, $_SESSION, and maybe even $_REQUEST.

--
paperCrane Justin Patrin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: session help

2003-03-01 Thread Niels Andersen

 i am having a terrible time killing the session
 someone please please help me...

This one works for me:
session_start();
$_SESSION = array();
session_destroy();

But I am surprised that there is no single command to kill the session.
The semantics of session_destroy() suggest that it does just that. But, as
you have found out, it does not...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Session help

2001-11-14 Thread Johan Holst Nielsen

 Start at index.html. It goes to postcard.php. When I click on submit in
 postcard.php, if I change any of the values in the form, the session
 values received in send_mail.php do not change. Anyone have an idea what
 I have done wrong now?
 

Try to make a session_unregister(), and make session_register() again with 
the new values.

Think it will help you :o)

Regards,

Johan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]