[PHP] Another Session Question

2003-12-31 Thread Al
There is a little code that worked before my virtual host before they 
updated to 4.3.1.

First time the function is called session should be set, subsequent 
calls should be skipped.

session_start();   

   if($_SESSION['counter_file'] !==$counterFile)//See if 
visitor has already been counted for this page
   {$num += 1;   
   $_SESSION['counter_file'] = $counterFile;
   }

echo $_SESSION['counterFile'] . '  testx  ' . $counterFile;

$_SESSION['counterFile'] shows nothing, even the first time through

$counterFile shows just fine. 

Al..

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


Re: [PHP] Another Session Question

2003-12-31 Thread Matt Matijevich
[snip]
session_start();   

if($_SESSION['counter_file'] !==$counterFile)//See if 
visitor has already been counted for this page
{$num += 1;   
$_SESSION['counter_file'] = $counterFile;
}

echo $_SESSION['counterFile'] . '  testx  ' . $counterFile;
[/snip]

might just be a typeo but do you mean: echo $_SESSION['counter_file'] .
'  testx  ' . $counterFile;
instead of this: echo $_SESSION['counterFile'] . '  testx  ' .
$counterFile;
?

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



Re: [PHP] Another Session Question

2003-12-31 Thread Al
Your'e right, that's a typo.

If I put a

echo $_SESSION['counter_file'] .
'  testx  ' . $counterFile;
Before and after the conditional, $_SESSION['counter_file'] is set after the conditional, as it should be.  But, it is gone from the before echo when the function is recalled.  

The Session buffer looses the value. 

session_start() is called again before returning to the function; but, I thought repeated session_starts() were ignored and thus should not restart the session. 

I use the session buffer extensively in other places without any problem.

Matt Matijevich wrote:

[snip]
session_start();   

   if($_SESSION['counter_file'] !==$counterFile)//See if 
visitor has already been counted for this page
   {$num += 1;   
   $_SESSION['counter_file'] = $counterFile;
   }

echo $_SESSION['counterFile'] . '  testx  ' . $counterFile;
[/snip]
might just be a typeo but do you mean: echo $_SESSION['counter_file'] .
'  testx  ' . $counterFile;
instead of this: echo $_SESSION['counterFile'] . '  testx  ' .
$counterFile;
?
 

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


[PHP] Another Session Question

2003-06-09 Thread Pushpinder Singh Garcha
Hello all,

I have php ver 4.1.1 running with register_globals() ON on my site.  I 
am trying to use sessions to maintain state during a visit to the site. 
I have read thru the manual, but my mind is still cluttered with 
doubts. I understand that use of the $_SESSION global array will 
greatly add to the security of the site and will prevent variable 
poisoning.

How do I register a session?
The manual (http://www.php.net/manual/en/print/ref.session.php) says 
that there are 2 methods:

Example 1. Registering a variable with $_SESSION.
?php
session_start();
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
} else {
$_SESSION['count']++;
}
?
---

Example 4. Registering a variable with register_globals enabled
?php
if (!session_is_registered('count')) {
session_register(count);
$count = 0;
}
else {
$count++;
}
?
-

This is a snippet of the code that I am testing:
? session_start();
require_once('../Connections/MasterStream.php');
if ( $_POST['validuser']  ($_POST['password']) ) {
mysql_select_db($database_MasterStream, $MasterStream);
$query_Recordset1 = SELECT * FROM `admin` WHERE `admin`.username = 
$_POST['validuser'] AND `admin`.password = $_POST['password'];
$Recordset1 = mysql_query($query_Recordset1, $MasterStream) or 
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

if ($totalRows_Recordset1)
{
echo Success!br;
  if(!isset($_SESSION['validuser']))
  $_SESSION['validuser'] = 0;
  else $_SESSION['validuser']++;
}

else{
echo Please try again laterbr;
}
}
?
Thanks in advance,
Pushpinder

Re: [PHP] Another Session Question

2003-06-09 Thread CPT John W. Holmes
So does your code work? Here's a tip: Try a simple example, like what's in
the manual, and see which method works for you. If they both work, which one
do you understand? Use that one...

---John Holmes...

- Original Message - 
From: Pushpinder Singh Garcha [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, June 09, 2003 4:23 PM
Subject: [PHP] Another Session Question


Hello all,


I have php ver 4.1.1 running with register_globals() ON on my site.  I
am trying to use sessions to maintain state during a visit to the site.
I have read thru the manual, but my mind is still cluttered with
doubts. I understand that use of the $_SESSION global array will
greatly add to the security of the site and will prevent variable
poisoning.

How do I register a session?
The manual (http://www.php.net/manual/en/print/ref.session.php) says
that there are 2 methods:

Example 1. Registering a variable with $_SESSION.
?php
session_start();
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['count'])) {
 $_SESSION['count'] = 0;
} else {
 $_SESSION['count']++;
}
?

---


Example 4. Registering a variable with register_globals enabled
?php
if (!session_is_registered('count')) {
 session_register(count);
 $count = 0;
}
else {
 $count++;
}
?

-

This is a snippet of the code that I am testing:
? session_start();
require_once('../Connections/MasterStream.php');

if ( $_POST['validuser']  ($_POST['password']) ) {
mysql_select_db($database_MasterStream, $MasterStream);
$query_Recordset1 = SELECT * FROM `admin` WHERE `admin`.username =
$_POST['validuser'] AND `admin`.password = $_POST['password'];
$Recordset1 = mysql_query($query_Recordset1, $MasterStream) or
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

if ($totalRows_Recordset1)
{
echo Success!br;
   if(!isset($_SESSION['validuser']))
   $_SESSION['validuser'] = 0;
  else $_SESSION['validuser']++;

}

else{
echo Please try again laterbr;
}
}
?

Thanks in advance,
Pushpinder


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



[PHP] Another Session Question

2002-03-25 Thread John Fishworld

I've seen various tutorials on sessions where they specify the session id
instead of just using one
generated by php !

Why ?



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




[PHP] Another Session Question..

2002-03-12 Thread Gonzalez, Zara E

I asked a question the other day about turning $_REQUEST variables into
$_SESSION variables...thanks, all who helped me with that...

I have another question about assigning $_REQUEST variables to $_SESSION
variables that I am hoping someone can help me out with

Here is a snippit of code...

while($r = mssql_fetch_array($result)) {
$vname = $group_abbr . $count;

$_SESSION[$vname] = $_REQUEST[$vname]; 
}

Now an explanation...
$vname is the actual name of the variable that is stored in the $_REQUEST array
(and what I want it to be called in the $_SESSION array) can I do this: ? (for
example, a1 so $_SESSION['a1'] = $_REQUEST['a1']; is what I want it to do...but
I need to send the name of the variable as a variable...)

I tried this...

$_SESSION[$vname] = $_REQUEST[$vname];

...but it doesn't seem to be working and I can't figure out how to get those
variables registered

Any help is much appreciated.

Zara


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




RE: [PHP] Another Session Question..

2002-03-12 Thread Gonzalez, Zara E

What I am trying to do is register a variable already in the request array...as
a session variable.

I know I can do $_SESSION['foo'] = $_REQUEST['foo'] but that's if I know the
name of the variable that was registered on the form side I do know the
name, but it's dynamically generated.

So for example, the name could be foo1 - foo10 and I want to register all of
them as session variables. 

So I want to be able to do this:
$count = 1;
$varname = foo . $count;

then do this:

$_SESSION[$varname] = $_REQUEST[$varname]

where the value of varname is actually the name of the variable that I want to
pull outDoes that make any sense?

I don't think that I can do $_SESSION['varname'] = $_REQUEST['varname'] in this
case because I don't want the value of varname as a session variableI want
the value of the value of varname as a session variable. 

I'm not sure if I can do this...but I'd assume there has got to be some way, I
just don't know what it is.

Also, apparently the php manual warns not to use $_SESSION['var'] = $var with
session_register and session_unregister. So that wouldn't work for me anyway.
(http://www.php.net/manual/en/function.session-register.php)

Zara

-Original Message-
From: Coggeshall, John [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, March 12, 2002 3:38 PM
To: Gonzalez, Zara E
Subject: RE: [PHP] Another Session Question..


If you are trying to register any variable... Say $foo...

Session_register('foo');

It will automatically appear in the $_SESSION array next time a page is
requested. I'm pretty sure it even will do it immediately (put it in
$_SESSION)

John


-Original Message-
From: Gonzalez, Zara E [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, March 12, 2002 4:23 PM
To: '[EMAIL PROTECTED]'
Subject: [PHP] Another Session Question..


I asked a question the other day about turning $_REQUEST variables into
$_SESSION variables...thanks, all who helped me with that...

I have another question about assigning $_REQUEST variables to $_SESSION
variables that I am hoping someone can help me out with

Here is a snippit of code...

while($r = mssql_fetch_array($result)) {
$vname = $group_abbr . $count;

$_SESSION[$vname] = $_REQUEST[$vname]; 
}

Now an explanation...
$vname is the actual name of the variable that is stored in the
$_REQUEST array (and what I want it to be called in the $_SESSION array)
can I do this: ? (for example, a1 so $_SESSION['a1'] = $_REQUEST['a1'];
is what I want it to do...but I need to send the name of the variable as
a variable...)

I tried this...

$_SESSION[$vname] = $_REQUEST[$vname];

...but it doesn't seem to be working and I can't figure out how to get
those variables registered

Any help is much appreciated.

Zara


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

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




RE: [PHP] Another Session Question..

2002-03-12 Thread Gonzalez, Zara E

On second look, perhaps it is working correctly.

I wasn't incrementing my counter variable. Sorry to flood your mailboxes.

Zara

-Original Message-
From: Gonzalez, Zara E 
Sent: Tuesday, March 12, 2002 3:47 PM
To: 'Coggeshall, John'; '[EMAIL PROTECTED]'
Subject: RE: [PHP] Another Session Question..

What I am trying to do is register a variable already in the request array...as
a session variable.

I know I can do $_SESSION['foo'] = $_REQUEST['foo'] but that's if I know the
name of the variable that was registered on the form side I do know the
name, but it's dynamically generated.

So for example, the name could be foo1 - foo10 and I want to register all of
them as session variables. 

So I want to be able to do this:
$count = 1;
$varname = foo . $count;

then do this:

$_SESSION[$varname] = $_REQUEST[$varname]

where the value of varname is actually the name of the variable that I want to
pull outDoes that make any sense?

I don't think that I can do $_SESSION['varname'] = $_REQUEST['varname'] in this
case because I don't want the value of varname as a session variableI want
the value of the value of varname as a session variable. 

I'm not sure if I can do this...but I'd assume there has got to be some way, I
just don't know what it is.

Also, apparently the php manual warns not to use $_SESSION['var'] = $var with
session_register and session_unregister. So that wouldn't work for me anyway.
(http://www.php.net/manual/en/function.session-register.php)

Zara

-Original Message-
From: Coggeshall, John [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, March 12, 2002 3:38 PM
To: Gonzalez, Zara E
Subject: RE: [PHP] Another Session Question..


If you are trying to register any variable... Say $foo...

Session_register('foo');

It will automatically appear in the $_SESSION array next time a page is
requested. I'm pretty sure it even will do it immediately (put it in
$_SESSION)

John


-Original Message-
From: Gonzalez, Zara E [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, March 12, 2002 4:23 PM
To: '[EMAIL PROTECTED]'
Subject: [PHP] Another Session Question..


I asked a question the other day about turning $_REQUEST variables into
$_SESSION variables...thanks, all who helped me with that...

I have another question about assigning $_REQUEST variables to $_SESSION
variables that I am hoping someone can help me out with

Here is a snippit of code...

while($r = mssql_fetch_array($result)) {
$vname = $group_abbr . $count;

$_SESSION[$vname] = $_REQUEST[$vname]; 
}

Now an explanation...
$vname is the actual name of the variable that is stored in the
$_REQUEST array (and what I want it to be called in the $_SESSION array)
can I do this: ? (for example, a1 so $_SESSION['a1'] = $_REQUEST['a1'];
is what I want it to do...but I need to send the name of the variable as
a variable...)

I tried this...

$_SESSION[$vname] = $_REQUEST[$vname];

...but it doesn't seem to be working and I can't figure out how to get
those variables registered

Any help is much appreciated.

Zara


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

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

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




RE: [PHP] Another Session Question..

2002-03-12 Thread Jan Rademaker

On Tue, 12 Mar 2002, Gonzalez, Zara E wrote:

 On second look, perhaps it is working correctly.
 
 I wasn't incrementing my counter variable. Sorry to flood your mailboxes.
 
 Zara
 

this should work as well;

foreach($_REQUEST as $key = $val) {
$_SESSION[$key] = $val;
}

-- 
Jan Rademaker [EMAIL PROTECTED]
http://www.ottobak.com



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