Re: [PHP] help with session

2007-08-31 Thread Dan
You should be sanatizing code here.  When you save it to the session and 
when it's output.  Look arround the newsgroups or online for info about it, 
it's everywhere.


- Dan

"mike" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

On 8/26/07, Jason Cartledge <[EMAIL PROTECTED]> wrote:

I would replace $_REQUEST with $_GET or $_POST (as appropriate)


  if ( !empty($_REQUEST['gender']) )
 {
   $registrationGender=$_REQUEST['gender'];
 }
 else {


Personally I would use if(isset($_SESSION['registrationGender'])) here


if (session_is_registered('registrationGender'))
 {
  $registrationGender=$_SESSION['registrationGender'];
  print "you are preregistered as a $registrationGender";
 }
 else
 {
  print "your gender is unknown, youare assumed to be a 
male";


   $_SESSION['registrationGender']='male';

I would change it to assign it here. No need to assign it a second
time below, since you are just printing the session variable if it is
already set


 }
  }



Those are a couple quick things my tired bloodshot eyes thought of.



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



Re: [PHP] help with session

2007-08-26 Thread Wouter van Vliet / Interpotential
I would go for:

if (isset($_REQUEST['gender'])) $_SESSION['registrationGender'] =
$_REQUEST['gender'];
print isset($_SESSION['registrationGender']) ? "You are registered as
gender: ".$_SESSION['registrationGender'] : "Your gender is unknown";

And make no assumptions about a gender when you don't know any ;-)

On 26/08/07, Jason Cartledge <[EMAIL PROTECTED]> wrote:
>
>
> Hi, this is my first post to this newsgroup. Does this code look ok or is
> there a more clean way of doing this? I am learning. Thank you for reading.
> Jason
>
>if ( !empty($_REQUEST['gender']) )
>   {
> $registrationGender=$_REQUEST['gender'];
>   }
>   else {
>  if (session_is_registered('registrationGender'))
>   {
>$registrationGender=$_SESSION['registrationGender'];
>print "you are preregistered as a $registrationGender";
>   }
>   else
>   {
>print "your gender is unknown, youare assumed to be a
> male";
>$registrationGender="male";
>   }
>}
>
> $_SESSION['registrationGender']=$registrationGender;
>
> _
> 100's of Music vouchers to be won with MSN Music
> https://www.musicmashup.co.uk/index.html
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Interpotential.com
Phone: +31615397471


Re: [PHP] help with session

2007-08-26 Thread mike
On 8/26/07, Jason Cartledge <[EMAIL PROTECTED]> wrote:

I would replace $_REQUEST with $_GET or $_POST (as appropriate)

>   if ( !empty($_REQUEST['gender']) )
>  {
>$registrationGender=$_REQUEST['gender'];
>  }
>  else {

Personally I would use if(isset($_SESSION['registrationGender'])) here

> if (session_is_registered('registrationGender'))
>  {
>   $registrationGender=$_SESSION['registrationGender'];
>   print "you are preregistered as a $registrationGender";
>  }
>  else
>  {
>   print "your gender is unknown, youare assumed to be a male";

$_SESSION['registrationGender']='male';

I would change it to assign it here. No need to assign it a second
time below, since you are just printing the session variable if it is
already set

>  }
>   }
>

Those are a couple quick things my tired bloodshot eyes thought of.

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



[PHP] help with session

2007-08-26 Thread Jason Cartledge

Hi, this is my first post to this newsgroup. Does this code look ok or is there 
a more clean way of doing this? I am learning. Thank you for reading.
Jason

   if ( !empty($_REQUEST['gender']) )
  {
$registrationGender=$_REQUEST['gender'];
  }
  else {
 if (session_is_registered('registrationGender'))
  {
   $registrationGender=$_SESSION['registrationGender'];
   print "you are preregistered as a $registrationGender";
  }
  else
  {
   print "your gender is unknown, youare assumed to be a male";
   $registrationGender="male";
  }
   }

$_SESSION['registrationGender']=$registrationGender;

_
100’s of Music vouchers to be won with MSN Music
https://www.musicmashup.co.uk/index.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with session needed

2003-03-09 Thread Jack
On Sun, 9 Mar 2003 21:18:33 +0100
"Øystein Håland" <[EMAIL PROTECTED]> wrote:

> The problem is the cookie soon reaches the 4 kb limit, so I would like to
> achieve the same using session. The trouble is, I don't know how to do. I
> would appreciate any help that brings me closer to a solution on this.

have a look in the manual:

http://www.php.net/manual/en/ref.session.php

in the middle of that page are some examples, which may help you.

bye

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



[PHP] Help with session needed

2003-03-09 Thread Øystein Håland
Today I collect information from several forms and store it in a cookie:

function formCookie() {
 var cookieValue = document.$formName.totalAns.value+'|';
 cookieValue
+=document.form1.correct.value+'$test[1]'+document.form1.question1.value+doc
ument.form1.answer.value+'|';
 cookieValue
+=document.form2.correct.value+'$test[1]'+document.form2.question2.value+doc
ument.form2.answer.value+'|';



 document.cookie = '$ansCookie='+escape(cookieValue)+';expires=';
}

The problem is the cookie soon reaches the 4 kb limit, so I would like to
achieve the same using session. The trouble is, I don't know how to do. I
would appreciate any help that brings me closer to a solution on this.



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



[PHP] Help with session needed

2003-02-21 Thread Øystein Håland
I use cookies in my web applications, but have reached the 4 kB limit. So I
need to 'convert' all my cookies to session variables. Have got an idea how
I can create such for one variable, but here I have multi element cookies.
Reading the php manual gives me no idea on how to do this.
Here's the recipe for my cookies:
function formCookie() {
 var cookieValue = document.$formname.totalAns.value+'|'; // Using '|' to
split each part of the cookie
 cookieValue +=
document.form1.correct.value+'$test[1]'+document.form1.question1.value+docum
ent.form1.answer.value+'|';
 cookieValue +=
document.form2.correct.value+'$test[1]'+document.form2.question2.value+docum
ent.form2.answer.value+'|';



 document.cookie = '$answercookie='+escape(cookieValue)+';expires=';
}

How can I achieve the same using sessions



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




Re: [PHP] Help with session variables

2002-12-04 Thread Stephen
Instead of register, set it up like a normal variable. Here's an examlple
going by your code:

Page1.
session_start();
$HTTP_SESSION_VARS['step'] = 1;
header("Location: page_A.php");

Page A
session_start();
$HTTP_SESSION_VARS['step'] = 2;
header("Location: page_B.php");

Page B.
session_start();
echo $HTTP_SESSION_VARS['step']; // You can echo it out straight, don't need
to extract it

Hope it works!

- Original Message -
From: "Manuel Ochoa" <[EMAIL PROTECTED]>
To: "PHP General" <[EMAIL PROTECTED]>
Sent: Wednesday, December 04, 2002 1:12 AM
Subject: [PHP] Help with session variables


>
> I'm running PHP 4.3 on a Windows .net server with Apache 2. Please look at
the following code as I cannot figure out what I'm doing wrong.
>
> Page1.
> session_start();
> session_register("step");
> $step=1;
> header("location: page_A.php");
>
> Page_A.
> session_start();
> extract($_SESSION);
> $step=2;
> header("location: page_B.php");
>
> Page_B.
> session_start();
> extract($_SESSION);
> print("$step");
>
> Output is always "1". I thought that session variables were global? What
am I doing wrong?
>


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




Re: [PHP] Help with session variables

2002-12-03 Thread Jason Wong
On Wednesday 04 December 2002 14:12, Manuel Ochoa wrote:
> I'm running PHP 4.3 on a Windows .net server with Apache 2. Please look at
> the following code as I cannot figure out what I'm doing wrong.
>
> Page1.
> session_start();
> session_register("step");
> $step=1;
> header("location: page_A.php");
>
> Page_A.
> session_start();
> extract($_SESSION);
> $step=2;
> header("location: page_B.php");
>
> Page_B.
> session_start();
> extract($_SESSION);
> print("$step");
>
> Output is always "1". I thought that session variables were global? What am
> I doing wrong?

If register_globals is disabled then you DO NOT use the session_register(), 
session_unregister() functions. 

You set them directly using: $_SESSION['step'] = 2
You remove them using: unset($_SESSION['step'])

If register_globals is enabled THEN you use the session_register(), 
session_unregister() functions. In which case in your examples above, the use 
of extract($_SESSION) is meaningless, and you need to 
session_register('step'), then $step = 2.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
You have taken yourself too seriously.
*/


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




[PHP] Help with session variables

2002-12-03 Thread Manuel Ochoa

I'm running PHP 4.3 on a Windows .net server with Apache 2. Please look at the 
following code as I cannot figure out what I'm doing wrong.

Page1.
session_start();
session_register("step");
$step=1;
header("location: page_A.php");

Page_A.
session_start();
extract($_SESSION);
$step=2;
header("location: page_B.php");

Page_B.
session_start();
extract($_SESSION);
print("$step");

Output is always "1". I thought that session variables were global? What am I doing 
wrong?



[PHP] help with session variables

2002-11-28 Thread Thomas Goeminne
";
}
 include ('./footer.php');
 ?>

What i need is to declare the arrays $names and $prices
And select the prodid as key and the title as val how can I do this?

I tried "select prodid as key, title as val
but that doesnt work.

thx for any help



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




Re: [PHP] Help with session

2001-02-15 Thread Richard Lynch

I think you want the session_start() and session_register() calls at the top
of the script, not buried in your if() statements.

--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
- Original Message -
From: "Karl J. Stubsjoen" <[EMAIL PROTECTED]>
Newsgroups: php.general
Sent: Thursday, February 15, 2001 11:36 AM
Subject: [PHP] Help with session


> I have 2 functions on my page, RegisterUser, IsValidUser.
> RegisterUser looks in the querystring to see if you've passed a certain
key
> & value.   If you have it populates a session variable called "ValidUser"
> with a 1.
> All that IsValidUser does, is check to see if the session variable
> "ValidUser" is a 1 or not.
>
> It doesn't work.
> RegisterUser (which sets session variables) is taking place before headers
> are written to the browser.  I'm not gettin errors, but the problem is
that
> ValidUser isn't able to read the session variable for some reason.
>
> Any Ideas?
>
> Here is the code for these 2 functions:
>
> function IsValidUser()
> {
> global $HTTP_SESSION_VARS;
>
> $reslt = 0;
>
>   if (isset($HTTP_SESSION_VARS["ValidUser"]))
>{
> if ($HTTP_SESSION_VARS["ValidUser"] == "1")
>  $reslt = 1;
>   }
>   print("ValidUser? " . $HTTP_SESSION_VARS["ValidUser"] . "");
>
> return($reslt);
> }
>
>
> function RegisterUser()
> {
> global $HTTP_SESSION_VARS;
> global $HTTP_GET_VARS;
> $reslt = 0;
>
> if (isset($HTTP_SESSION_VARS["ValidUser"]))
> {
>  if ($HTTP_SESSION_VARS["ValidUser"] == 1)
>  {
>$reslt = 1;
>  }
> }
>
> if ($reslt=0);
> {
>
>  $Val_User = $HTTP_GET_VARS["fis"];
>
>  if ($Val_User == "1")
>  {
>   $reslt = 1;
>  if (!isset($HTTP_SESSION_VARS["ValidUser"]))
>  {
> session_start();
>  session_register("ValidUser");
>  $HTTP_SESSION_VARS["ValidUser"] = 1;
> }
> else
> {
>  $HTTP_SESSION_VARS["ValidUser"] = 1;
> }
>  }
>  else
>  {
>  $reslt = 0;
>  }
> }
> return($reslt);
> }
>
>
>
> --
> 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]
>


-- 
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]




[PHP] Help with session

2001-02-15 Thread Karl J. Stubsjoen

I have 2 functions on my page, RegisterUser, IsValidUser.
RegisterUser looks in the querystring to see if you've passed a certain key
& value.   If you have it populates a session variable called "ValidUser"
with a 1.
All that IsValidUser does, is check to see if the session variable
"ValidUser" is a 1 or not.

It doesn't work.
RegisterUser (which sets session variables) is taking place before headers
are written to the browser.  I'm not gettin errors, but the problem is that
ValidUser isn't able to read the session variable for some reason.

Any Ideas?

Here is the code for these 2 functions:

function IsValidUser()
{
global $HTTP_SESSION_VARS;

$reslt = 0;

  if (isset($HTTP_SESSION_VARS["ValidUser"]))
   {
if ($HTTP_SESSION_VARS["ValidUser"] == "1")
 $reslt = 1;
  }
  print("ValidUser? " . $HTTP_SESSION_VARS["ValidUser"] . "");

return($reslt);
}


function RegisterUser()
{
global $HTTP_SESSION_VARS;
global $HTTP_GET_VARS;
$reslt = 0;

if (isset($HTTP_SESSION_VARS["ValidUser"]))
{
 if ($HTTP_SESSION_VARS["ValidUser"] == 1)
 {
   $reslt = 1;
 }
}

if ($reslt=0);
{

 $Val_User = $HTTP_GET_VARS["fis"];

 if ($Val_User == "1")
 {
  $reslt = 1;
 if (!isset($HTTP_SESSION_VARS["ValidUser"]))
 {
session_start();
 session_register("ValidUser");
 $HTTP_SESSION_VARS["ValidUser"] = 1;
}
else
{
 $HTTP_SESSION_VARS["ValidUser"] = 1;
}
 }
 else
 {
 $reslt = 0;
 }
}
return($reslt);
}



-- 
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]