[PHP] Session-variables

2001-02-05 Thread spider

Is it ok to mail questions to this list? If so;

Is there something similar like the "session variables" of ASP in PHP,
or do one have
to use (client-side) cookies instead?

/thanks/me


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

2001-05-03 Thread Nikhil Goyal

When does a session variable become available? Immediately after the
session_register command or after the script ends?

And if the commands are as follows:

session_start();
session_register("hello");
$hello=3;

will the session variable $hello be set to 3 or do I have to add another
session_register() call after changing the value?

Really appreciate any help,

Nikhil



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

2002-12-17 Thread Antti
How can I change the values of session variables 
(session_register('variable');) in a session. Do I just 
unset($variable); and do session_register() again and give it a new 
value. I tried this and it seems that it doesn't work.

Antti


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



[PHP] Session Variables

2002-03-25 Thread Chad Gilmer

Hi There,

I am a beginner to PHP and I am tring to use session variables on my site.

I am trying to use Session Variables in PHP on the iPLANIT.tv site

When I use the following code:



I get the following error

Warning: Cannot send session cookie - headers already sent by (output
started at /home/iplanit/public_html/php/login.php:8) in
/home/iplanit/public_html/php/login.php on line 11

Warning: Cannot send session cache limiter - headers already sent (output
started at /home/iplanit/public_html/php/login.php:8) in
/home/iplanit/public_html/php/login.php on line 11

Any Ideas???

Cheers

Chad



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




[PHP] session variables

2002-04-04 Thread Lee, Ford

I seem to have configuration problemsi just can't seem to get
session variables written to in files under win2000, NTFS w/ Apache and
PHP..i've already done everything from session_start() on every page
to making var globalanybody can help??  thanksbtw, i got the
same system on a Linux box running apache and php and it works fine


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




[PHP] Session Variables

2002-04-16 Thread Phil Powell

I understand the concept of session variables, so I want to know the best
methodology of approaching this:

1) HTML redirect to PHP page
2) PHP page looks for session
  a) If found, show some stuff
  b) If not found, prompt user for username and password
3) If no session, prompt user for username and password, once entered & is
ok, set session and redirect

Following is a code snippet I borrowed that I think would work, correct me
if I'm wrong:

// Setting a name for our session.
session_name("hasLoggedIn");
// Starting Session.
session_start();
// Register vars into session
session_register("username");
// Setting values for session vars.
$HTTP_SESSION_VARS["username"]=$HTTP_POST_VARS["username"];
// Referring a session info to another PHP.
echo "text";

Thanx!!
Phil




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




[PHP] Session variables

2002-07-08 Thread Steve Fitzgerald

I am designing a form using sessions in which the user inputs their
details on page 1 and after submitting they are directed to page 2 for
confirmation. They then have the option of editing their input (ie they
are returned to page 1) where their previous input is reflected in the
form fields by
value =''
This works fine except if the input type is a drop down box, in which
case the default  is shown. Is there any way around this? How
can I show the user their previous choice in these boxes?
Any insights would be appreciated.
Steve


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




[PHP] Session Variables

2001-07-25 Thread Jason Bell

Is there anyway to prevent session variables from being overwritten by a get string?

I'm wanting to use sessions for security/login, but I'm finding that I can bypass this 
very easily. For example, I want to hide menu items based on security level, so I use 
something like this:

if ($HTTP_SESSION_VARS["sess_auth"] > 2) { print "News 
Editor"; };

which works, however, it can be bypassed if someone just enters the value in the url 
like so:

http://secured.site.com/index.php?sess_auth=admin

is there any way around this using sessions?  Is there a far more suitable method?

Thanks!

Jason Bell



[PHP] Session variables

2001-09-07 Thread Ing. Lalka Peter

Hi!
I want to know how many users are currently online at my site. 
How can I get this info from php? Can I?
Thank you for answer.
Barno


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

2001-04-10 Thread george

I am using a session to store a variable so when someone enters something
into a field the persons username(which is stored in the session) is also
entered into anoter field.
  The problem is that it only works the first time, so how can I make the
session last for a required length of time, so that if the person leaves the
site and returns without the login then the variable is still stored and
entered into the field.

 Thanks in advance.

George




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

2009-02-06 Thread Paul M Foster
I'm not too clear on HTTP headers, cookies, and such. So here are
questions related to that. Let's say I generate a random number that I
want the user to enter in a form. When I generate the number, I store it
in a session variable ($_SESSION). When the user submits the form, I
check the number they enter with what I've stored in the session
variable.

Since this session variable survives across page loads (assuming
session_start() is appropriately called), how is it stored and recalled?

Is it automatically stored as a cookie on the user's system? 

Or is it stored on the server? 

And how does a server "get" a cookie? 

Is it a separate request made by the server to the client? 

If the value I've asked the user for is *not* stored as a cookie, then
is it passed as part of the HTTP submission or what?

Thanks for any enlightenment on this.

Paul
-- 
Paul M. Foster

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



[PHP] SESSION variables

2008-10-11 Thread Ron Piggott
I am programming a blog.

index.php sets up the layout for the web page.  This includes the
heading, left hand and bottom menus.  

The content  is loaded by the command:

include($filename);

the $_SESSION variables aren't available to files like blog.php .  The
session variables only work in the initial file, index.php. 

I am NOT using frames.  The web page is loaded all at the same time.
Simply when index.php is done, it passes the "baton" to the next .php
file to display the specific information the user is requesting.  

Any ideas / suggestions?

Ron


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



[PHP] Session Variables

2003-01-26 Thread Jed R. Brubaker
I have a quirky problem that should be a breeze for someone who is smarter
than I.

I have a script where I am registering a HTML form post variable as a
session variable and then echo it. In the real script I use it in a MySQL
query, but for the sake of this post, here is the "script":

$user1 = $HTTP_POST_VARS["user1"];
session_register("user1");
echo $HTTP_SESSION_VARS["user1"];

This doesn't work, however, if I hit the refresh button the var miraculously
appears!
What am I doing wrong?



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




[PHP] session variables

2003-03-13 Thread Shaun van den Berg
Hi,

Is it wise or wrong to put long strings into a session variable ? Is it
better to keep the values short ?

Thanks
Shaun

--
Novtel Consulting
Tel: +27 21 9822373
Fax: +27 21 9815846
Please visit our website:
www.novtel.co.za



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



[PHP] session variables

2003-08-29 Thread Diana Castillo
I am having a weird problem, when I close all my browser windows and restart
my application, the session variable which I set comes back suddenly, but
only when I call a certain class .

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



[PHP] session variables

2003-09-01 Thread Diana Castillo
I am having a weird problem, when I close all my browser windows and restart
my application, the session variable which I set comes back suddenly, but
only when I call a certain class .
As far as I know the session variables should disappear when I close the
browser.  Why would they suddenly come back?
thank you

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



[PHP] session variables

2003-03-19 Thread Pag
	HI,

	Am trying to give controlled access to who logs in to my site. Have a 
quick doubt:

	I register a session var named $tu (value is taken from the DB) when a 
user logs in, how can i reference to that var? I mean, if i want to check 
its value, if i do print($tu);, it doesnt seem to work.
	Thanks.

	Pag



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


[PHP] session variables

2004-01-22 Thread Diana Castillo
If you store session variables , but the user has session cookies disabled,
is there any way to recuperate those session variables?


--
--
Diana Castillo
Global Reservas, S.L.
C/Granvia 22 dcdo 4-dcha
28013 Madrid-Spain
Tel : 00-34-913604039
Fax : 00-34-915228673
email: [EMAIL PROTECTED]
Web : http://www.hotelkey.com
  http://www.destinia.com

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



[PHP] SESSION VARIABLES

2004-02-09 Thread Ronald Ramos
Hi All,

I've created 3 sample scripts, pls see below.
My problem is that page3.php can't display the value $username and
$password
Or is it because it the variables were not importe to that page, that's
why
$username and $password has no value? If it is, how can I import it?

Thank you

- login.php -






  
  USERNAME: 
  PASSWORD: 
  






-- auth.php -






function bukas() {
window.open(\"page3.php\",\"_new\");
};



$username

";
}

else {
echo "INVALID, TRY AGAIN";
};
?>

--- page3.php --



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



[PHP] session variables

2004-04-20 Thread Charles Collins
I have two test files running on a server, which is giving me a headache,
due to the fact the session variables are not been maintained across the two
pages.

The server is running ...

PHP Version  = 4.0.5
register_globals = ON
Session Support = Enabled
session.auto_start = Off
session.cache_expire =  180
session.cache_limiter = nocache
session.cookie_domain = inweb.net.uk
session.cookie_lifetime = 600
session.cookie_path =  /
session.cookie_secure = Off
session.entropy_file = no value
session.entropy_length = 0
session.gc_maxlifetime = 1440
session.gc_probability = 1
session.name = PHPSESSID
session.referer_check = no value
session.save_handler = files
session.save_path = /tmp
session.serialize_handler php
session.use_cookies = On

The two script files are as follows: -

Page #1:



Page # 2



Can anyone tell me where I'm going wrong, works fine of test servers, etc.,
only screwed up when site was lauched.

Thanks in advance ...

Regards
Charlie.

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



[PHP] session variables

2004-06-01 Thread Bob Lockie
$_SESSION['new_name'] = $_REQUEST['new_name'];
Is not global.
I printed out the value locally but it is not made into a session variable.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Session-variables

2001-02-05 Thread Hardy Merrill

Look at
   http://www.php.net/manual/en/html/ref.session.html

HTH.

-- 
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

spider [[EMAIL PROTECTED]] wrote:
> Is it ok to mail questions to this list? If so;
> 
> Is there something similar like the "session variables" of ASP in PHP,
> or do one have
> to use (client-side) cookies instead?
> 
> /thanks/me
> 
> 
> -- 
> 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]




RE: [PHP] Session Variables

2001-05-03 Thread Johnson, Kirk

> -Original Message-
> From: Nikhil Goyal [mailto:[EMAIL PROTECTED]]

> When does a session variable become available? Immediately after the
> session_register command or after the script ends?

Immediately after it is assigned.

> And if the commands are as follows:
> 
> session_start();
> session_register("hello");
> $hello=3;
> 
> will the session variable $hello be set to 3 or do I have to 
> add another
> session_register() call after changing the value?

No additional calls are needed. You will need to do session_start() on the
next page if you want to access $hello there.

Kirk

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




Re: [PHP] Session Variables

2001-05-03 Thread Nikhil Goyal

Funnily - doesn't work for me. Here's what I got:

Script #1
#!/usr/local/bin/php


Script #2
#!/usr/local/bin/php


If I start script#1 (and it sleep()s), wait 10 seconds, then launch script
#2 in a separate browser window, script #2 returns empty. However once the
sleep() is completed and I refresh the window with script #2, the output is
okay (1).

Why does this happen?

Nikhil

""Johnson, Kirk"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > -Original Message-
> > From: Nikhil Goyal [mailto:[EMAIL PROTECTED]]
>
> > When does a session variable become available? Immediately after the
> > session_register command or after the script ends?
>
> Immediately after it is assigned.
>
> > And if the commands are as follows:
> >
> > session_start();
> > session_register("hello");
> > $hello=3;
> >
> > will the session variable $hello be set to 3 or do I have to
> > add another
> > session_register() call after changing the value?
>
> No additional calls are needed. You will need to do session_start() on the
> next page if you want to access $hello there.
>
> Kirk
>
> --
> 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]




RE: [PHP] Session Variables

2001-05-03 Thread Johnson, Kirk

The session variable values get stored to the session file (or database, or
wherever your configuration is set to store them) at the end of script 1.
When session_start() is called in script 2, those values get restored from
the session file. So, your results are expected: PHP  needs to store the
session values from script 1 before they can be retrieved by script 2.

Kirk

> -Original Message-
> From: Nikhil Goyal [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 03, 2001 2:41 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Session Variables
> 
> 
> Funnily - doesn't work for me. Here's what I got:
> 
> Script #1
> #!/usr/local/bin/php
>  session_start();
> if (!isset($count)) { echo "Setting count"; 
> session_register("count"); }
> else echo $count;
> $count++;
> sleep(60);
> ?>
> 
> Script #2
> #!/usr/local/bin/php
>  session_start();
> echo $count;
> ?>
> 
> If I start script#1 (and it sleep()s), wait 10 seconds, then 
> launch script
> #2 in a separate browser window, script #2 returns empty. 
> However once the
> sleep() is completed and I refresh the window with script #2, 
> the output is
> okay (1).
> 
> Why does this happen?
> 
> Nikhil
> 
> ""Johnson, Kirk"" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > -Original Message-
> > > From: Nikhil Goyal [mailto:[EMAIL PROTECTED]]
> >
> > > When does a session variable become available? 
> Immediately after the
> > > session_register command or after the script ends?
> >
> > Immediately after it is assigned.
> >
> > > And if the commands are as follows:
> > >
> > > session_start();
> > > session_register("hello");
> > > $hello=3;
> > >
> > > will the session variable $hello be set to 3 or do I have to
> > > add another
> > > session_register() call after changing the value?
> >
> > No additional calls are needed. You will need to do 
> session_start() on the
> > next page if you want to access $hello there.
> >
> > Kirk 

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




Re: [PHP] Session Variables

2001-05-03 Thread Nikhil Goyal

so the session variable is set only when the script ends? I thought you
indicated that they were set immediately...

Thanks for the quick reply,

Nikhil

""Johnson, Kirk"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> The session variable values get stored to the session file (or database,
or
> wherever your configuration is set to store them) at the end of script 1.
> When session_start() is called in script 2, those values get restored from
> the session file. So, your results are expected: PHP  needs to store the
> session values from script 1 before they can be retrieved by script 2.
>
> Kirk
>
> > -Original Message-
> > From: Nikhil Goyal [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, May 03, 2001 2:41 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [PHP] Session Variables
> >
> >
> > Funnily - doesn't work for me. Here's what I got:
> >
> > Script #1
> > #!/usr/local/bin/php
> >  > session_start();
> > if (!isset($count)) { echo "Setting count";
> > session_register("count"); }
> > else echo $count;
> > $count++;
> > sleep(60);
> > ?>
> >
> > Script #2
> > #!/usr/local/bin/php
> >  > session_start();
> > echo $count;
> > ?>
> >
> > If I start script#1 (and it sleep()s), wait 10 seconds, then
> > launch script
> > #2 in a separate browser window, script #2 returns empty.
> > However once the
> > sleep() is completed and I refresh the window with script #2,
> > the output is
> > okay (1).
> >
> > Why does this happen?
> >
> > Nikhil
> >
> > ""Johnson, Kirk"" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > -Original Message-
> > > > From: Nikhil Goyal [mailto:[EMAIL PROTECTED]]
> > >
> > > > When does a session variable become available?
> > Immediately after the
> > > > session_register command or after the script ends?
> > >
> > > Immediately after it is assigned.
> > >
> > > > And if the commands are as follows:
> > > >
> > > > session_start();
> > > > session_register("hello");
> > > > $hello=3;
> > > >
> > > > will the session variable $hello be set to 3 or do I have to
> > > > add another
> > > > session_register() call after changing the value?
> > >
> > > No additional calls are needed. You will need to do
> > session_start() on the
> > > next page if you want to access $hello there.
> > >
> > > Kirk
>
> --
> 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]




RE: [PHP] Session Variables

2001-05-03 Thread Johnson, Kirk

Sorry for the confusion. The variable has a value as soon as you assign it,
and you can use the variable in other statements within the same script.
However, the value does not get stored to the session file until after the
script ends.

Kirk

> -Original Message-
> From: Nikhil Goyal [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 03, 2001 2:51 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Session Variables
> 
> 
> so the session variable is set only when the script ends? I 
> thought you
> indicated that they were set immediately...
> 
> Thanks for the quick reply,
> 
> Nikhil
> [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]




Re: [PHP] session variables

2002-12-17 Thread Justin French
1. the opposite of 
session_register('varname') is
session_unregister('varname') NOT
unset($varname)


2. Are you on PHP >= 4.1 ??

If so, move away from things like:



and into:



MUCH cleaner to work with :)


Justin



on 17/12/02 10:35 PM, Antti ([EMAIL PROTECTED]) wrote:

> How can I change the values of session variables
> (session_register('variable');) in a session. Do I just
> unset($variable); and do session_register() again and give it a new
> value. I tried this and it seems that it doesn't work.
> 
> Antti
> 

Justin French

http://Indent.com.au
Web Development & 
Graphic Design



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




Re: [PHP] session variables

2002-12-18 Thread Antti
Justin French wrote:

1. the opposite of 
session_register('varname') is
session_unregister('varname') NOT
unset($varname)


2. Are you on PHP >= 4.1 ??

If so, move away from things like:


session_start();
$variable = 'foo';
session_register('variable');
session_unregister('variable')
?>

and into:


session_start();
$_SESSION['variable'] = 'foo';
$_SESSION['variable'] = 'bah';
unset($_SESSION['variable']);
?>

MUCH cleaner to work with :)


Justin



on 17/12/02 10:35 PM, Antti ([EMAIL PROTECTED]) wrote:


How can I change the values of session variables
(session_register('variable');) in a session. Do I just
unset($variable); and do session_register() again and give it a new
value. I tried this and it seems that it doesn't work.

Antti




Justin French

http://Indent.com.au
Web Development & 
Graphic Design


Neather this seem to work

$_SESSION['some_variable']=$variable;

nor this:

$_SESSION['today']= date('Y-m-d h:m:s');

antti



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




Re: [PHP] session variables

2002-12-18 Thread Antti
Justin French wrote:

1. the opposite of 
session_register('varname') is
session_unregister('varname') NOT
unset($varname)


2. Are you on PHP >= 4.1 ??

If so, move away from things like:


session_start();
$variable = 'foo';
session_register('variable');
session_unregister('variable')
?>

and into:


session_start();
$_SESSION['variable'] = 'foo';
$_SESSION['variable'] = 'bah';
unset($_SESSION['variable']);
?>

MUCH cleaner to work with :)


Justin



on 17/12/02 10:35 PM, Antti ([EMAIL PROTECTED]) wrote:


How can I change the values of session variables
(session_register('variable');) in a session. Do I just
unset($variable); and do session_register() again and give it a new
value. I tried this and it seems that it doesn't work.

Antti




Justin French

http://Indent.com.au
Web Development & 
Graphic Design


Neather this seem to work

$_SESSION['ses_name']=$variable;

nor this:

$_SESSION['today']= date('Y-m-d h:m:s');

antti



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




Re: [PHP] session variables

2002-12-18 Thread Justin French
on 19/12/02 2:25 AM, Antti ([EMAIL PROTECTED]) wrote:

> Neather this seem to work
> 
> $_SESSION['some_variable']=$variable;
> 
> nor this:
> 
> $_SESSION['today']= date('Y-m-d h:m:s');
> 
> antti

What do you mean "don't work"... what are you trying to do?


page1.php



click to go to page 2



page2.php



The value of $_SESSION['today'] is .




This code assumes you either have trans-sid compiled OR are allowing cookies
on your browser AND cookies is a method that PHP sessions use (it is by
default) in php.ini.



Justin French

http://Indent.com.au
Web Development & 
Graphic Design



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




RE: [PHP] Session Variables

2002-03-25 Thread Rick Emery

it means you've already output some HTML or a blank line


-Original Message-
From: Chad Gilmer [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 12:19 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Session Variables


Hi There,

I am a beginner to PHP and I am tring to use session variables on my site.

I am trying to use Session Variables in PHP on the iPLANIT.tv site

When I use the following code:



I get the following error

Warning: Cannot send session cookie - headers already sent by (output
started at /home/iplanit/public_html/php/login.php:8) in
/home/iplanit/public_html/php/login.php on line 11

Warning: Cannot send session cache limiter - headers already sent (output
started at /home/iplanit/public_html/php/login.php:8) in
/home/iplanit/public_html/php/login.php on line 11

Any Ideas???

Cheers

Chad



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

2002-04-04 Thread Wolfram Kriesing

On Thursday 04 April 2002 19:15, Lee, Ford wrote:
> I seem to have configuration problemsi just can't seem to get
> session variables written to in files under win2000, NTFS w/ Apache and
> PHP..i've already done everything from session_start() on every page
> to making var globalanybody can help??  thanksbtw, i got the
> same system on a Linux box running apache and php and it works fine

this is a bug in PHP 4.1.2 on win
   http://bugs.php.net/?id=16423
i am also looking for a workaround  :-(
-- 
Wolfram

... translating template engine 
  http://sf.net/projects/simpletpl

... authentication system 
  http://sf.net/projects/auth

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




RE: [PHP] session variables

2002-04-04 Thread Lee, Ford

I've even tried the new php4apache.dll that was on that bug list and
still did not work.  I'm suprised nobody else has this session problem
on Windows 2000 and Apache...

-Original Message-
From: Wolfram Kriesing [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 12:21 PM
To: Lee, Ford; [EMAIL PROTECTED]
Subject: Re: [PHP] session variables


On Thursday 04 April 2002 19:15, Lee, Ford wrote:
> I seem to have configuration problemsi just can't seem to get
> session variables written to in files under win2000, NTFS w/ Apache
and
> PHP..i've already done everything from session_start() on every
page
> to making var globalanybody can help??  thanksbtw, i got the
> same system on a Linux box running apache and php and it works
fine

this is a bug in PHP 4.1.2 on win
   http://bugs.php.net/?id=16423
i am also looking for a workaround  :-(
-- 
Wolfram

... translating template engine 
  http://sf.net/projects/simpletpl

... authentication system 
  http://sf.net/projects/auth


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




RE: [PHP] session variables

2002-04-04 Thread Lee, Ford

Apparently under the bug report database for bug number 16043, my
exactly problem was described.  According to the PHP team, this
windows/apache1.3.23/php4.1.2 session not writing to file bug has been
fixed in the 4.2.0RC1 binaries.  I've patched my php4apache.dll with the
ones from 4.2.0RC1 AND it still doesn't work!!!  Anyone who used
4.2.0RC1 came across this problem and made it work?


-Original Message-
From: SHEETS,JASON (Non-HP-Boise,ex1) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 12:43 PM
To: Lee, Ford
Subject: RE: [PHP] session variables


This isn't limited to windows 2000, I've seen it on nt and xp as well.
I
believe it is just a php on windows bug in general.  I've heard 4.1.1
was
not broken however 4.1.1 has a security hole, if you are just using
windows
as a test/development platform you may consider trying 4.1.1.

Jason

-Original Message-
From: Lee, Ford [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 10:33 AM
To: Wolfram Kriesing
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] session variables


I've even tried the new php4apache.dll that was on that bug list and
still did not work.  I'm suprised nobody else has this session problem
on Windows 2000 and Apache...

-Original Message-
From: Wolfram Kriesing [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 12:21 PM
To: Lee, Ford; [EMAIL PROTECTED]
Subject: Re: [PHP] session variables


On Thursday 04 April 2002 19:15, Lee, Ford wrote:
> I seem to have configuration problemsi just can't seem to get
> session variables written to in files under win2000, NTFS w/ Apache
and
> PHP..i've already done everything from session_start() on every
page
> to making var globalanybody can help??  thanksbtw, i got the
> same system on a Linux box running apache and php and it works
fine

this is a bug in PHP 4.1.2 on win
   http://bugs.php.net/?id=16423
i am also looking for a workaround  :-(
-- 
Wolfram

... translating template engine 
  http://sf.net/projects/simpletpl

... authentication system 
  http://sf.net/projects/auth


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

2002-04-04 Thread heinisch

At 04.04.2002  13:18, you wrote:
>Apparently under the bug report database for bug number 16043, my
>exactly problem was described.  According to the PHP team, this
>windows/apache1.3.23/php4.1.2 session not writing to file bug has been
>fixed in the 4.2.0RC1 binaries.  I've patched my php4apache.dll with the
>ones from 4.2.0RC1 AND it still doesn't work!!!  Anyone who used
>4.2.0RC1 came across this problem and made it work?


>This isn't limited to windows 2000, I've seen it on nt and xp as well.
>I
>believe it is just a php on windows bug in general.  I've heard 4.1.1
>was
>not broken however 4.1.1 has a security hole, if you are just using
>windows
>as a test/development platform you may consider trying 4.1.1.


You´re on the wrong list, windowsPHPuser is the right one!
This is php-general.
HTH Oliver


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




RE: [PHP] Session Variables

2002-04-16 Thread .ben

I have a function that i call at the beginning of each page (well, those
that require user auth).

checkLogin()

this checks for a positive integer value in a session variable called
intUserID

$_SESSION['intUserID'];

is that isn't a positive integer, i redirect to the login page.

the login is split into two script, prompt and process.  prompt is a form
which  POSTs data to the process script which in turn verifys the
username/password and if valid, assigns $_SESSION['intUserID'] the value of
the users user ID.

all looks fine to me.

 .b

p.s. is it just me or is the reply-to on this list a little odd?

> -Original Message-
> From: Phil Powell [mailto:[EMAIL PROTECTED]]
> Sent: 16 April 2002 22:50
> To: [EMAIL PROTECTED]
> Subject: [PHP] Session Variables
>
>
> I understand the concept of session variables, so I want to know the best
> methodology of approaching this:
>
> 1) HTML redirect to PHP page
> 2) PHP page looks for session
>   a) If found, show some stuff
>   b) If not found, prompt user for username and password
> 3) If no session, prompt user for username and password, once entered & is
> ok, set session and redirect
>
> Following is a code snippet I borrowed that I think would work, correct me
> if I'm wrong:
>
> // Setting a name for our session.
> session_name("hasLoggedIn");
> // Starting Session.
> session_start();
> // Register vars into session
> session_register("username");
> // Setting values for session vars.
> $HTTP_SESSION_VARS["username"]=$HTTP_POST_VARS["username"];
> // Referring a session info to another PHP.
> echo "text";
>
> Thanx!!
> Phil
>
>
>
>
> --
> 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] Session variables

2002-07-08 Thread Rudolf Visagie

Generate a select structure dynamically with PHP, something like this:

";
for ($i = 0; $i <= count($OptionValue) - 1; $i++) {
if ($SelectedValue != "" && $OptionValue[$i] ==
$SelectedValue) {
echo "".$Option[$i]."";
} else {
echo "".$Option[$i]."";
}
}
echo "";
return 0;
}
?>


Untitled Document










Untitled Document





";
GenerateSelect ("MyList", $OptionValue, $Option, $MyList)
?>






Regards

Rudolf Visagie
Principal Software Developer
Digital Healthcare Solutions
<mailto:[EMAIL PROTECTED]>
Tel: 011 2655478
Cell: 082 895 1598
 

-Original Message-
From: Steve Fitzgerald [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 08, 2002 1:36 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Session variables


I am designing a form using sessions in which the user inputs their
details on page 1 and after submitting they are directed to page 2 for
confirmation. They then have the option of editing their input (ie they
are returned to page 1) where their previous input is reflected in the
form fields by
value =''
This works fine except if the input type is a drop down box, in which
case the default  is shown. Is there any way around this? How
can I show the user their previous choice in these boxes?
Any insights would be appreciated.
Steve


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

2002-07-08 Thread Justin French


>
>
>
>
>
>


Obviously this is labourios to code... you can do this a lot smarter/quicker
with an array for the entire select box... have an array of days, and do a
foreach loop which writes the all the options for you, with the if
statements, etc etc.

By the way, this has nothing to do with sessions :)

It's purely about how to populate drop-down menus from an array, and how to
have the correct value selected if it exists, else showing a default
selection.

Cheers,

Justin French



on 08/07/02 9:36 PM, Steve Fitzgerald ([EMAIL PROTECTED]) wrote:

> I am designing a form using sessions in which the user inputs their
> details on page 1 and after submitting they are directed to page 2 for
> confirmation. They then have the option of editing their input (ie they
> are returned to page 1) where their previous input is reflected in the
> form fields by
> value =''
> This works fine except if the input type is a drop down box, in which
> case the default  is shown. Is there any way around this? How
> can I show the user their previous choice in these boxes?
> Any insights would be appreciated.
> Steve
> 


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




Re: [PHP] Session variables

2002-07-08 Thread Steve Fitzgerald

Thanks Justin, your solution is spot-on!
Regards
Steve

Justin French wrote:

> 
>  ?>>
> >
>  ?>>
>  } ?>>
>  ?>>
> >
> 
>
> Obviously this is labourios to code... you can do this a lot smarter/quicker
> with an array for the entire select box... have an array of days, and do a
> foreach loop which writes the all the options for you, with the if
> statements, etc etc.
>
> By the way, this has nothing to do with sessions :)
>
> It's purely about how to populate drop-down menus from an array, and how to
> have the correct value selected if it exists, else showing a default
> selection.
>
> Cheers,
>
> Justin French
>
> on 08/07/02 9:36 PM, Steve Fitzgerald ([EMAIL PROTECTED]) wrote:
>
> > I am designing a form using sessions in which the user inputs their
> > details on page 1 and after submitting they are directed to page 2 for
> > confirmation. They then have the option of editing their input (ie they
> > are returned to page 1) where their previous input is reflected in the
> > form fields by
> > value =''
> > This works fine except if the input type is a drop down box, in which
> > case the default  is shown. Is there any way around this? How
> > can I show the user their previous choice in these boxes?
> > Any insights would be appreciated.
> > Steve
> >


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




RE: [PHP] Session Variables

2001-07-25 Thread Johnson, Kirk

> Is there anyway to prevent session variables from being 
> overwritten by a get string?

PHP will do this automatically *if* you initialize your session variables to
*anything* as soon as you register them. For example,

session_register("sess_auth");
$sess_auth = "";

If you do this, then session variables will overwrite GET/POST variables,
and the latter will need to be retrieved from the $HTTP_(GET/POST)_VARS
arrays.

Another approach is to turn register_globals off in php.ini. This is a long
one to explain, but has been covered quite bit here- search the archive.

Kirk

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




RE: [PHP] Session Variables

2001-07-25 Thread Sascha Schumann

On Wed, 25 Jul 2001, Johnson, Kirk wrote:

> > Is there anyway to prevent session variables from being
> > overwritten by a get string?
>
> PHP will do this automatically *if* you initialize your session variables to
> *anything* as soon as you register them. For example,
>
> session_register("sess_auth");
> $sess_auth = "";

Note that session_register() will implicitly commence the
session, and thus will automatically instantiate all session
variables.  Hence, the above two lines need to be reversed,
otherwise you might overwrite the session variable.

- Sascha Experience IRCG
  http://schumann.cx/http://schumann.cx/ircg


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




Re: [PHP] Session Variables

2001-07-25 Thread Jason Bell

Thanks! I changed my code to the following and it plugged that hole.  :)


if (!$PHPSESSID) {
$sess_auth = "";
session_register('sess_auth');
  }



- Original Message -
From: "Sascha Schumann" <[EMAIL PROTECTED]>
To: "Johnson, Kirk" <[EMAIL PROTECTED]>
Cc: "PHP Users" <[EMAIL PROTECTED]>
Sent: Wednesday, July 25, 2001 2:10 PM
Subject: RE: [PHP] Session Variables


> On Wed, 25 Jul 2001, Johnson, Kirk wrote:
>
> > > Is there anyway to prevent session variables from being
> > > overwritten by a get string?
> >
> > PHP will do this automatically *if* you initialize your session
variables to
> > *anything* as soon as you register them. For example,
> >
> > session_register("sess_auth");
> > $sess_auth = "";
>
> Note that session_register() will implicitly commence the
> session, and thus will automatically instantiate all session
> variables.  Hence, the above two lines need to be reversed,
> otherwise you might overwrite the session variable.
>
> - Sascha Experience IRCG
>   http://schumann.cx/http://schumann.cx/ircg
>
>
> --
> 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]




Re: [PHP] session variables

2001-04-10 Thread mailing_list

> I am using a session to store a variable so when someone enters something
> into a field the persons username(which is stored in the session) is also
> entered into anoter field.
>   The problem is that it only works the first time, so how can I make the
> session last for a required length of time, so that if the person leaves
> the
> site and returns without the login then the variable is still stored and
> entered into the field.

that's not a session-issue!
use COOKIES

witty

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net


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




Re: [PHP] session variables

2001-04-10 Thread george


  I tried using a cookie I still had the same problem that it worked first
time but even if you stayed on the page and put a sencond entry in it would
not work,

George



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




Re: [PHP] session variables

2001-04-10 Thread mailing_list

>   I tried using a cookie I still had the same problem that it worked first
> time but even if you stayed on the page and put a sencond entry in it
> would
> not work,

then you:
set the cookie incorrectly
overwrite/delete the cookie by mistake
your browser does not support cookies
...

read
http://php.net/manual/en/features.cookies.php
and
http://php.net/manual/en/function.setcookie.php

try the example there!

witty

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net


-- 
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] Session Variables & Cookies

2001-04-17 Thread Bob Clingan

I've tried to follow the example in the online manual, but and I believe my
session/cookie variables are being stored. Is there some specific way I need
to call them? Can anyone provide a brief example?

Thanks.

--Bob
--

  +---+
  |  Bob Clingan| OneStopSite, LLC|
  | | www.onestopsite.com |
  |  Web Developer/Programmer   | Phone: 410-893-9800 |
  |  [EMAIL PROTECTED]| Fax:   410-893-8065 |
  +---+



-- 
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] session variables - help

2009-08-13 Thread Allen McCabe
I am asking a similar question to one I asked yesterday (which received no
answers) with more information in the hopes someone will be kind enough to
guide me.

I have an order form populated with an array (as opposed to a database
table). The user can enter quantities, and the form posts all the
information to the order_process page where the values they entered are
listed for review.

I decided I wanted to allow them to edit quantities before actually
submitting the form (by which I mean before using the mail() function).

I found that $_SESSION is the way to go.

On the order summary page (order_process.php), I start a session and I get
all the POST information via:

[code]

session_start();

extract($_POST);

[/code]

Instead of echoing the quantity values of each item, I populate an input
field with them within an echo:

[code]

//when this function is called, $a is a the quantity variable $show_01_qty
function writeResultRow($a, $b, $c, $d, $e, $f) {
 if($a != '') {
  echo "";
  . . .
}
[/code]

Now, in order to update a quantity, the user replaces the quantity in the
input field with the new number, and clicks a submit button which posts to
order_update.php.

I have the following code for order_update.php:

[code]

session_start();
extract($_POST);
foreach ($_POST as $var => $val) {
 if ($val > 0) {
  $_SESSION[$var] = $val;
 } else {
  unset($var);

 }
 header("Location: order_process.php");
}

[/code]

This is not working, however, and it just loads order_process.php with no
values for the varaibles, as if I just refreshed the page with no sessions.

Help please!


[PHP] Session Variables - Error

2011-03-30 Thread Ethan Rosenberg

Dear List -

Thanks for your help.

Here is another one.

I cannot get my session variables to work. The program will print out 
a chess board and show the positions of the pieces after the move


Here are code snippets: The program is chess2.php


$results = array(array("Br", "Bn", "Bb", "Bq", "Bk", "Bb", "Bn", 
"Br"),array("Bp", "Bp", "Bp", "Bp", "Bp", "Bp", "Bp", "Bp"),
array("", "", "", "", "", "", "", 
""),array("", "", "", "", "", "", "", ""),array("", "", "", "", "", 
"", "", ""),
array("", "", "", "", "", "", "", 
""),array("Wp", "Wp", "Wp", "Wp", "Wp", "Wp", "Wp", "Wp"),
array("Wr", "Wn", "Wb", "Wq", "Wk", "Wb", 
"Wn", "Wr"));


$_SESSION['results'] = $results;
print_r($_SESSION);
}
else
{
 $results = $_SESSION['results'];
 echo "starting values";
 print_r($results);
}
?>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

http://www.w3.org/1999/xhtml";>

.
.
.
.
.

Move Fromname="move_from">
Move To  name="move_to">





";
echo "from_before = "; print_r($from_before);
echo"";
$to = '$'. $_POST[move_to];
echo "to = $to";
//$to = $from;
$from = '' ;
echo"";
echo "from after = $from";
echo"";
echo "to after = $to";

$board = array  //Correlation of input array [chessboard] with 
internal array [results]

(
a8 => $results[0][0],
b8 => $results[0][1],
c8 => $results[0][2],
d8 => $results[0][3],
e8 => $results[0][4],
f8 => $results[0][5],
.
.
.
.
f1 => $results[7][5],
g1 => $results[7][6],
h1 => $results[7][7],
);
for($i = 0; $i <8; $i++) //  I get the correct results here
{
for ($j = 0; $j < 8; 
$j++)

printf("%s ", $results[$i][$j]);
printf("");
}
$_SESSION['results'] = $results;



Ethan 




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



Re: [PHP] Session variables

2009-02-06 Thread Phpster
A Session is stored on the user browser in a session ( in memory  
cookie) and on the server as a file. The session mgmt tools will read  
the file as needed.


Bastien

Sent from my iPod

On Feb 7, 2009, at 1:58, Paul M Foster  wrote:


I'm not too clear on HTTP headers, cookies, and such. So here are
questions related to that. Let's say I generate a random number that I
want the user to enter in a form. When I generate the number, I  
store it

in a session variable ($_SESSION). When the user submits the form, I
check the number they enter with what I've stored in the session
variable.

Since this session variable survives across page loads (assuming
session_start() is appropriately called), how is it stored and  
recalled?


Is it automatically stored as a cookie on the user's system?

Or is it stored on the server?

And how does a server "get" a cookie?

Is it a separate request made by the server to the client?

If the value I've asked the user for is *not* stored as a cookie, then
is it passed as part of the HTTP submission or what?

Thanks for any enlightenment on this.

Paul
--
Paul M. Foster

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

2009-02-06 Thread German Geek
The session data is stored on the server. In the user's browser, only a
session cookie is stored, usually a random session id string. I could never
retrieve the session variables with any browser tools, always only with PHP
by echoing them out or something. Also, a cookie is simply a text file with
a maximum of 4096 characters on the user's browser, not enough to store big
session variables with big objects. So, the user's browser just stores a
cookie with the session id, so that the server knows which user to map to
which session variables. The session variables (in PHP) are stored in the
temporary directory on the server in a text file (flattened or serialized),
where the server can retrieve them across requests. This is important for
security reasons. You might not want the user to be able to view certain
variables in their browser otherwise they could change them and cause some
damage, e.g. imagine a user has a permission level between 1 and 10 and 1 is
the super user. You can store this level in a session variable, and the user
cannot change it. If they could, it would be a disaster! Also, if one could
store more than 4096 characters, it would be relatively easy to write out
some session variables in order to flood the browser memory and make it
crash or even worse.

Oh, and the Cookies, as far as i know, are always sent in the http headers.
They are stored on both client and server and can be set on both sides, with
javascript or server side code (php). So they can only be checked in every
request by the server side code, and while javascript is being executed on
the client.

Please correct me if I'm wrong because I would need to review a lot of code
in which it is assumed that session variables are NOT stored on the user's
machine.


Makes sense?

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Sat, Feb 7, 2009 at 8:11 PM, Phpster  wrote:

> A Session is stored on the user browser in a session ( in memory cookie)
> and on the server as a file. The session mgmt tools will read the file as
> needed.
>
> Bastien
>
> Sent from my iPod
>
>
> On Feb 7, 2009, at 1:58, Paul M Foster  wrote:
>
>  I'm not too clear on HTTP headers, cookies, and such. So here are
>> questions related to that. Let's say I generate a random number that I
>> want the user to enter in a form. When I generate the number, I store it
>> in a session variable ($_SESSION). When the user submits the form, I
>> check the number they enter with what I've stored in the session
>> variable.
>>
>> Since this session variable survives across page loads (assuming
>> session_start() is appropriately called), how is it stored and recalled?
>>
>> Is it automatically stored as a cookie on the user's system?
>>
>> Or is it stored on the server?
>>
>> And how does a server "get" a cookie?
>>
>> Is it a separate request made by the server to the client?
>>
>> If the value I've asked the user for is *not* stored as a cookie, then
>> is it passed as part of the HTTP submission or what?
>>
>> Thanks for any enlightenment on this.
>>
>> Paul
>> --
>> Paul M. Foster
>>
>> --
>> 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] Session variables

2009-02-07 Thread Stuart
2009/2/7 Paul M Foster :
> I'm not too clear on HTTP headers, cookies, and such. So here are
> questions related to that. Let's say I generate a random number that I
> want the user to enter in a form. When I generate the number, I store it
> in a session variable ($_SESSION). When the user submits the form, I
> check the number they enter with what I've stored in the session
> variable.
>
> Since this session variable survives across page loads (assuming
> session_start() is appropriately called), how is it stored and recalled?
>
> Is it automatically stored as a cookie on the user's system?
>
> Or is it stored on the server?
>
> And how does a server "get" a cookie?
>
> Is it a separate request made by the server to the client?
>
> If the value I've asked the user for is *not* stored as a cookie, then
> is it passed as part of the HTTP submission or what?
>
> Thanks for any enlightenment on this.

Session data is stored on the server and tied to a browser using a
cookie. The cookie contains a random string which uniquely identifies
a session on the server. The session_start() function handles all the
details of setting and maintaining that cookie and managing the
server-side data.

Cookies are transferred between client and server with every request
in the headers. If you don't have Firefox getfirefox.com. The google
for the livehttpheaders addon and install that. Turn it on and browse
your site. You will see the cookies in the headers of both requests
and responses. Cookies are not stored on the server side, they are
sent by the client with each request.

No additional HTTP requests are involved when using sessions.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] Session variables

2009-02-07 Thread German Geek
Yeah i guess the cookie doesn't need to be stored on the server since it's
in the header anyway.

Thanks for clearing that up.

Tim-Hinnerk Heuer

http://www.ihostnz.com
Charles M. Schulz  - "I love mankind; it's people I can't stand."

2009/2/7 Stuart 

> 2009/2/7 Paul M Foster :
> > I'm not too clear on HTTP headers, cookies, and such. So here are
> > questions related to that. Let's say I generate a random number that I
> > want the user to enter in a form. When I generate the number, I store it
> > in a session variable ($_SESSION). When the user submits the form, I
> > check the number they enter with what I've stored in the session
> > variable.
> >
> > Since this session variable survives across page loads (assuming
> > session_start() is appropriately called), how is it stored and recalled?
> >
> > Is it automatically stored as a cookie on the user's system?
> >
> > Or is it stored on the server?
> >
> > And how does a server "get" a cookie?
> >
> > Is it a separate request made by the server to the client?
> >
> > If the value I've asked the user for is *not* stored as a cookie, then
> > is it passed as part of the HTTP submission or what?
> >
> > Thanks for any enlightenment on this.
>
> Session data is stored on the server and tied to a browser using a
> cookie. The cookie contains a random string which uniquely identifies
> a session on the server. The session_start() function handles all the
> details of setting and maintaining that cookie and managing the
> server-side data.
>
> Cookies are transferred between client and server with every request
> in the headers. If you don't have Firefox getfirefox.com. The google
> for the livehttpheaders addon and install that. Turn it on and browse
> your site. You will see the cookies in the headers of both requests
> and responses. Cookies are not stored on the server side, they are
> sent by the client with each request.
>
> No additional HTTP requests are involved when using sessions.
>
> -Stuart
>
> --
> http://stut.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] SESSION variables

2008-10-11 Thread Daniel Brown
On Sat, Oct 11, 2008 at 7:49 PM, Ron Piggott <[EMAIL PROTECTED]> wrote:
> I am programming a blog.
>
> index.php sets up the layout for the web page.  This includes the
> heading, left hand and bottom menus.
>
> The content  is loaded by the command:
>
> include($filename);
>
> the $_SESSION variables aren't available to files like blog.php .  The
> session variables only work in the initial file, index.php.

Did you remember to add session_start() to the head of the master
file that's including the other files?

-- 

More full-root dedicated server packages:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] SESSION variables

2008-10-11 Thread Ron Piggott

This is one of the first commands given.  

I am using modrewrites to call the blog entries.  

blog.php is responsible for displaying both the table of contents and
the blog entries.  When the table of contents is called
(http://www.rons-home.net/page/blog/ ) the session variables are
present.  When an actual blog entry is displayed
( http://www.rons-home.net/blog/28/ ) the session variables aren't
there.

I am not sure what is happening / why.  

The login is at http://www.rons-home.net/page/login/  It has 'page' in
the URL.  But I am not sure why this should upset the session
variables ...

Any thoughts?

Ron

On Sat, 2008-10-11 at 19:59 -0400, Daniel Brown wrote:
> On Sat, Oct 11, 2008 at 7:49 PM, Ron Piggott <[EMAIL PROTECTED]> wrote:
> > I am programming a blog.
> >
> > index.php sets up the layout for the web page.  This includes the
> > heading, left hand and bottom menus.
> >
> > The content  is loaded by the command:
> >
> > include($filename);
> >
> > the $_SESSION variables aren't available to files like blog.php .  The
> > session variables only work in the initial file, index.php.
> 
> Did you remember to add session_start() to the head of the master
> file that's including the other files?
> 


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



Re: [PHP] SESSION variables

2008-10-11 Thread Ron Piggott
I did some more testing.  The URL is the problem.  

Logins are from


On Sat, 2008-10-11 at 19:59 -0400, Daniel Brown wrote:
> On Sat, Oct 11, 2008 at 7:49 PM, Ron Piggott <[EMAIL PROTECTED]> wrote:
> > I am programming a blog.
> >
> > index.php sets up the layout for the web page.  This includes the
> > heading, left hand and bottom menus.
> >
> > The content  is loaded by the command:
> >
> > include($filename);
> >
> > the $_SESSION variables aren't available to files like blog.php .  The
> > session variables only work in the initial file, index.php.
> 
> Did you remember to add session_start() to the head of the master
> file that's including the other files?
> 


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



Re: [PHP] SESSION variables

2008-10-11 Thread Ron Piggott
Oops

Logins are from

http://www.rons-home.net/page/login-greeting/

Blog postings are from

http://www.rons-home.net/blog/28/

with the word 'page' gone the session variable doesn't acknowledge the
login.

Ron


On Sat, 2008-10-11 at 21:12 -0400, Ron Piggott wrote:
> I did some more testing.  The URL is the problem.  
> 
> Logins are from
> 
> 
> On Sat, 2008-10-11 at 19:59 -0400, Daniel Brown wrote:
> > On Sat, Oct 11, 2008 at 7:49 PM, Ron Piggott <[EMAIL PROTECTED]> wrote:
> > > I am programming a blog.
> > >
> > > index.php sets up the layout for the web page.  This includes the
> > > heading, left hand and bottom menus.
> > >
> > > The content  is loaded by the command:
> > >
> > > include($filename);
> > >
> > > the $_SESSION variables aren't available to files like blog.php .  The
> > > session variables only work in the initial file, index.php.
> > 
> > Did you remember to add session_start() to the head of the master
> > file that's including the other files?
> > 
-- 

Acts Ministries Christian Evangelism
Where People Matter
12 Burton Street
Belleville, Ontario, Canada 
K8P 1E6

[EMAIL PROTECTED]
www.actsministrieschristianevangelism.org

In Belleville Phone: (613) 967-0032
In North America Call Toll Free: (866) ACTS-MIN
Fax: (613) 967-9963


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



Re: [PHP] Session Variables

2003-01-27 Thread Leif K-Brooks
$HTTP_SESSION_VARS and $_SESSION don't magically update when you add a 
session variable with session_register().

Jed R. Brubaker wrote:

I have a quirky problem that should be a breeze for someone who is smarter
than I.

I have a script where I am registering a HTML form post variable as a
session variable and then echo it. In the real script I use it in a MySQL
query, but for the sake of this post, here is the "script":

$user1 = $HTTP_POST_VARS["user1"];
session_register("user1");
echo $HTTP_SESSION_VARS["user1"];

This doesn't work, however, if I hit the refresh button the var miraculously
appears!
What am I doing wrong?



 


--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.




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




RE: [PHP] session variables

2003-03-13 Thread John W. Holmes
> Is it wise or wrong to put long strings into a session variable ? Is
it
> better to keep the values short ?

The more data you put into your session, the more data that has to be
read and written to a file on your server each time someone accesses a
page. More data is going to slow things down. 

If it's your only option, then use it. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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



RE: [PHP] session variables

2003-09-01 Thread Binay Agarwal
Check out session.cookie_lifetime .. 
if lifetime =0 then session should disappear once you close the browser else it will 
stay the time specified in lifetime options.

Hope this helps and let me know.

Binay

"Diana Castillo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> I am having a weird problem, when I close all my browser windows and restart
> my application, the session variable which I set comes back suddenly, but
> only when I call a certain class .
> As far as I know the session variables should disappear when I close the
> browser.  Why would they suddenly come back?
> thank you



RE: [PHP] session variables

2003-03-19 Thread daniel
u have to start the session first then check with $_SESSION['tu'];
>= Original Message From Pag <[EMAIL PROTECTED]> =
>   HI,
>
>   Am trying to give controlled access to who logs in to my site. Have a
>quick doubt:
>
>   I register a session var named $tu (value is taken from the DB) when a
>user logs in, how can i reference to that var? I mean, if i want to check
>its value, if i do print($tu);, it doesnt seem to work.
>   Thanks.
>
>   Pag
>
>
>
>--
>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] session variables

2004-01-22 Thread Matt Matijevich

If you store session variables , but the user has session cookies
disabled,
is there any way to recuperate those session variables?


Yes, look at the  session.use_trans_sid variable.

http://www.php.net/session 

If cookies are disabled, php will pass the session id as a ur variable
or a hidden field.

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



Re: [PHP] session variables

2004-01-22 Thread John Nichel
Diana Castillo wrote:

If you store session variables , but the user has session cookies disabled,
is there any way to recuperate those session variables?
--
--
Diana Castillo
Global Reservas, S.L.
C/Granvia 22 dcdo 4-dcha
28013 Madrid-Spain
Tel : 00-34-913604039
Fax : 00-34-915228673
email: [EMAIL PROTECTED]
Web : http://www.hotelkey.com
  http://www.destinia.com
Session variables are stored on the web server.  A session cookie is 
used to carry the session id from page to page.  If the user has cookies 
disabled, the session can be passed in the URL.

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

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] session variables

2004-01-22 Thread Chris Shiflett
--- Diana Castillo <[EMAIL PROTECTED]> wrote:
> If you store session variables , but the user has session cookies
> disabled, is there any way to recuperate those session variables?

Cookies come in two types: session cookies and persistent cookies. Session
cookies have no set expiration date, so they expire as soon as the browser
session ends. Persistent cookies don't expire until the date indicated,
and this often involves persisting them in a file (cookies.txt, for
example).

So, I think you just mean to ask how to make sessions work when the user
has disabled cookies. Cookies are only used to propagate the session
identifier, so you don't lose session data. At worst, you would just be
unable to identify the user on the next request.

PHP handles this last potential problem for you with the
session.use_trans_sid php.ini directive. This will rewrite your URLs (in
links and such) to include the session identifier, and PHP will
automatically check both for the bookie and the URL variable. So, you will
probably not need to do anything special.

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/

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



Re: [PHP] SESSION VARIABLES

2004-02-09 Thread Adam Bregenzer
On Tue, 2004-02-10 at 00:43, Ronald Ramos wrote:
> Hi All,
> 
> I've created 3 sample scripts, pls see below.
> My problem is that page3.php can't display the value $username and
> $password
> Or is it because it the variables were not importe to that page, that's
> why
> $username and $password has no value? If it is, how can I import it?

You need to have session_start() at the top of the third script as
well.  Also you have a typo:
> echo "#password";

should be:
echo "$password";

Consider using $_SESSION[1] instead of session_register[2].

[1] http://www.php.net/reserved.variables#reserved.variables.session
[2] http://www.php.net/session_register

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



RE: [PHP] SESSION VARIABLES

2004-02-10 Thread Adam Bregenzer
On Tue, 2004-02-10 at 02:45, Ronald Ramos wrote:
> $_SESSION['username'];
> $_SESSION['password'];

Close, try this instead:
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;

> I edited page3.php but it still shows me nothing.

It looks great, now you just need to clear up your use of the $_SESSION
variable in page2.php.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



RE: [PHP] SESSION VARIABLES

2004-02-10 Thread Adam Bregenzer
On Tue, 2004-02-10 at 03:13, Ronald Ramos wrote:
> It Worked. Thanks Man!
> So I can use this to any other page?

Awesome!  You have access to the $_SESSION variables on any php page on
the same server.  Just make sure you call session_start() before you
access the $_SESSION array.

> Let's say I have two users, first one logged in, using ronald as
> username, while user ronald is still logged-in
> User nhadie also logged-in from somewhere, will the value of $username
> of user ronald be changed to nhadie?

No, with sessions there will essentially be multiple values for the
variables, one for each session.  When a user requests a page their
session id will be used to set the correct values in the $_SESSION
array.  For example, when ronald loads the page $_SESSION['username']
will be ronald.  When nhadie loads the page the $_SESSION['username']
variable will be nahdie.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



RE: [PHP] session variables

2004-04-20 Thread Vincent DUPONT
I would do
script 1 :
$_SESSION['test'] = "hello world";

and in script2 :
print($_SESSION['test']);


vincent

-Original Message-
From: Charles Collins [mailto:[EMAIL PROTECTED]
Sent: mardi 20 avril 2004 17:44
To: [EMAIL PROTECTED]
Subject: [PHP] session variables


I have two test files running on a server, which is giving me a headache,
due to the fact the session variables are not been maintained across the two
pages.

The server is running ...

PHP Version  = 4.0.5
register_globals = ON
Session Support = Enabled
session.auto_start = Off
session.cache_expire =  180
session.cache_limiter = nocache
session.cookie_domain = inweb.net.uk
session.cookie_lifetime = 600
session.cookie_path =  /
session.cookie_secure = Off
session.entropy_file = no value
session.entropy_length = 0
session.gc_maxlifetime = 1440
session.gc_probability = 1
session.name = PHPSESSID
session.referer_check = no value
session.save_handler = files
session.save_path = /tmp
session.serialize_handler php
session.use_cookies = On

The two script files are as follows: -

Page #1:



Page # 2



Can anyone tell me where I'm going wrong, works fine of test servers, etc.,
only screwed up when site was lauched.

Thanks in advance ...

Regards
Charlie.

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

2004-04-20 Thread Charles Collins
Dear Vincent,

Tried that as well as $HTTP_SERVER_VARS, $_SESSION, etc., still cannot get
the damn thing working.

Regards,
Charlie.

"Vincent Dupont" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
I would do
script 1 :
$_SESSION['test'] = "hello world";

and in script2 :
print($_SESSION['test']);


vincent

-Original Message-
From: Charles Collins [mailto:[EMAIL PROTECTED]
Sent: mardi 20 avril 2004 17:44
To: [EMAIL PROTECTED]
Subject: [PHP] session variables


I have two test files running on a server, which is giving me a headache,
due to the fact the session variables are not been maintained across the two
pages.

The server is running ...

PHP Version  = 4.0.5
register_globals = ON
Session Support = Enabled
session.auto_start = Off
session.cache_expire =  180
session.cache_limiter = nocache
session.cookie_domain = inweb.net.uk
session.cookie_lifetime = 600
session.cookie_path =  /
session.cookie_secure = Off
session.entropy_file = no value
session.entropy_length = 0
session.gc_maxlifetime = 1440
session.gc_probability = 1
session.name = PHPSESSID
session.referer_check = no value
session.save_handler = files
session.save_path = /tmp
session.serialize_handler php
session.use_cookies = On

The two script files are as follows: -

Page #1:



Page # 2



Can anyone tell me where I'm going wrong, works fine of test servers, etc.,
only screwed up when site was lauched.

Thanks in advance ...

Regards
Charlie.

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

2004-04-20 Thread Daniel Clark
hum.  Try $_SESSION['test'] on page 2.

> I have two test files running on a server, which is giving me a headache,
> due to the fact the session variables are not been maintained across the
> two
> pages.
>
> The server is running ...
>
> PHP Version  = 4.0.5
> register_globals = ON
> Session Support = Enabled
> session.auto_start = Off
> session.cache_expire =  180
> session.cache_limiter = nocache
> session.cookie_domain = inweb.net.uk
> session.cookie_lifetime = 600
> session.cookie_path =  /
> session.cookie_secure = Off
> session.entropy_file = no value
> session.entropy_length = 0
> session.gc_maxlifetime = 1440
> session.gc_probability = 1
> session.name = PHPSESSID
> session.referer_check = no value
> session.save_handler = files
> session.save_path = /tmp
> session.serialize_handler php
> session.use_cookies = On
>
> The two script files are as follows: -
>
> Page #1:
>
>   session_start();
>  session_register("test");
>  $test = "Hullo World";
>  print $test; // prints "test"
> ?>
>
> Page # 2
>
>   session_start();
>  print $test;// prints nothing, zip!
> ?>
>
> Can anyone tell me where I'm going wrong, works fine of test servers,
> etc.,
> only screwed up when site was lauched.

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



Re: [PHP] session variables

2004-04-20 Thread Daniel Clark
Does page1 call page2?
Or do you open another browser window and open page2?

My understanding is some browsers to NOT transfer the same session info to
another borwser window.

> Tried that as well as $HTTP_SERVER_VARS, $_SESSION, etc., still cannot get
> the damn thing working.
>
> Regards,
> Charlie.
>
> "Vincent Dupont" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> I would do
> script 1 :
> $_SESSION['test'] = "hello world";
>
> and in script2 :
> print($_SESSION['test']);
>
>
> vincent
>
> -Original Message-
> From: Charles Collins [mailto:[EMAIL PROTECTED]
> Sent: mardi 20 avril 2004 17:44
> To: [EMAIL PROTECTED]
> Subject: [PHP] session variables
>
>
> I have two test files running on a server, which is giving me a headache,
> due to the fact the session variables are not been maintained across the
> two
> pages.
>
> The server is running ...
>
> PHP Version  = 4.0.5
> register_globals = ON
> Session Support = Enabled
> session.auto_start = Off
> session.cache_expire =  180
> session.cache_limiter = nocache
> session.cookie_domain = inweb.net.uk
> session.cookie_lifetime = 600
> session.cookie_path =  /
> session.cookie_secure = Off
> session.entropy_file = no value
> session.entropy_length = 0
> session.gc_maxlifetime = 1440
> session.gc_probability = 1
> session.name = PHPSESSID
> session.referer_check = no value
> session.save_handler = files
> session.save_path = /tmp
> session.serialize_handler php
> session.use_cookies = On
>
> The two script files are as follows: -
>
> Page #1:
>
>   session_start();
>  session_register("test");
>  $test = "Hullo World";
>  print $test; // prints "test"
> ?>
>
> Page # 2
>
>   session_start();
>  print $test;// prints nothing, zip!
> ?>
>
> Can anyone tell me where I'm going wrong, works fine of test servers,
> etc.,
> only screwed up when site was lauched.

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



Re: [PHP] session variables

2004-04-20 Thread Curt Zirzow
* Thus wrote Charles Collins ([EMAIL PROTECTED]):
> I have two test files running on a server, which is giving me a headache,
> due to the fact the session variables are not been maintained across the two
> pages.
> 
> The server is running ...
> 
> PHP Version  = 4.0.5
> register_globals = ON
> Session Support = Enabled

This looks like output from 'php -i'. The php module *can* have a
different config, check these values from phpinfo() in  a webpage
in the same directory as your scripts with

> ...
> 
>   session_start();
>  session_register("test");
>  $test = "Hullo World";
>  print $test; // prints "test"
> ?>
> 
> Page # 2
> 
>   session_start();
>  print $test;// prints nothing, zip!
> ?>
I would strongly suggest using the $_SESSION variable, even if
register_globals is on, that way sessions work regardless of its
setting.

page 1:
session_start();
$test = $_SESSION['test'] = 'Hullo World';
echo $test;

page 2:
session_start();
$test = $_SESSION['test'];
echo $test;


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



Re: [PHP] session variables

2004-04-20 Thread Curt Zirzow
* Thus wrote Curt Zirzow ([EMAIL PROTECTED]):
> This looks like output from 'php -i'. The php module *can* have a
> different config, check these values from phpinfo() in  a webpage
> in the same directory as your scripts with

I fired my proofreader so I have to do this manually now :)

s/ with/.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



Re: [PHP] session variables

2004-06-01 Thread John Nichel
Bob Lockie wrote:
$_SESSION['new_name'] = $_REQUEST['new_name'];
Is not global.
I printed out the value locally but it is not made into a session variable.
Did you start the session before you set $_SESSION['new_name']?
--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] session variables

2004-06-01 Thread John W. Holmes
Bob Lockie wrote:
$_SESSION['new_name'] = $_REQUEST['new_name'];
Is not global.
I printed out the value locally but it is not made into a session variable.
Yes, it is. Providing you have sessions configured correctly and use 
session_start().

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] session variables

2004-06-01 Thread Bob Lockie
On 06/01/04 22:12 John Nichel spoke:
Bob Lockie wrote:
$_SESSION['new_name'] = $_REQUEST['new_name'];
Is not global.
I printed out the value locally but it is not made into a session 
variable.

Did you start the session before you set $_SESSION['new_name']?
That was my problem.
I reorganized and put some code in a file that didn't have a 
session_start() call. :-(

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


[PHP] session variables and classes?

2002-05-01 Thread John Ngo

does anyone know if a session variable set within a class is accessible
outside the class and by other pages?



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




[PHP] session variables in OOP....

2002-06-14 Thread Wilbert Enserink

Hi all,


I'm busy building a site which uses OOP. 
Several classes are used to constuct different sections of the final page to be 
displayed. 
The overall class is called class.basepage.php
This is the page which outputs HTML and calls other classes to construct other parts 
of the page.
Now I have this problem: In one of the objects I use session variables. However i get 
the famous error :Cannot send session cookie - headers already sent by (output 
started "


Is there a way to overcome this problem? I mean: the session variable is registered in 
the main part of the page after the class $this->header is called (which writes 
HTML)... now, I don't think I can register the sessionvariable at the top of my script 
since the value of the session var is determined in the main.class...or can I?

I hope you understand my problem and have some tips for me. Below is some code 
snippets I'm using:

thx and regards 

Wilbert Enserink



class.basebape.php---
  header(); ?>// includes a php file which writes HTMLcode functioning as 
the "header" of the HTML page (i.e. navigation menu)
 main(); ?> // includes a php file (main.php) which writes the main part 
of the HTML data
---

---main.php--
echo "a lot of HTML depending on queries and stuff";
session_register($variable);



output browser--
Warning: Cannot send session cookie - headers already sent by (output started at 
/opt/guide/www.designmatcher.com/HTML/wwwtest/class.basepage.php:125) in 
/opt/guide/www.abc.com/HTML/wwwtest/phpincludes/main/main.php on line 400
-

-
Pas de Deux
Van Mierisstraat 25
2526 NM Den Haag
tel 070 4450855
fax 070 4450852
http://www.pdd.nl
[EMAIL PROTECTED]
-


[PHP] session variables and unset

2002-04-10 Thread Valdas Andrulis

Hello,

I have 3 scripts:

## i2.php


## i.php


## i1.php


When I open http://host/i2.php on my browser I get 0, though I expect it
to be 4. If I uncomment session_unregister("counter"); I get 4 as
expected.

PHP version 4.1.2.

Anyone can explain this behavior? Also can anyone try this with say
4.0.5 or older version of PHP?

Good luck,

Valdas



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




Re[2]: [PHP] Session variables

2002-07-08 Thread Michal Dvoracek

> 
>  ?>>
> >
>  ?>>
>  } ?>>
>  ?>>
> >
> 

better is (IMHO):
>
>

Regards,
Michal Dvoracek  [EMAIL PROTECTED]


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




[PHP] Session Variables and Redirecting

2001-07-13 Thread Johnny Nguyen

I've done this on other platforms ASP,Cold Fusion, but I need to know what's
the best way to do it on PHP.

1. grab username and password from POST vars.
2. select count(*) from users where username = '$username' and
password='$password'... something along these lines
3. if that user exists and password matches, set a flag on the user and send
them to the right page, otherwise increment failed attempts and send them
back to login page.

if (count > 0)

session_register("someflag");
$HTTP_SESSION_VARS["someflag"] = somevalue;
header("Location: secretpage.php");
}
else

session_register("failedattempts");
$HTTP_SESSION_VARS["failedattempts"]++;
header("Location: loginpage.php");
}

but apparently, i can't start/register a session and then redirect.  Is
there a better way to do this?

Regards,
Johnny


-- 
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] Session variables - Users online

2001-09-07 Thread Aniceto Lopez

put this code in the home web page

$conn user online";
  } else {
  echo"$conn users online";
  }
?>

and create this table in you db to hold the necesary values

#
# Table structure for table 'uonline'
#

CREATE TABLE `uonline` (
  `caduc` int(15) NOT NULL default '0',
  `ip` varchar(40) NOT NULL default '',
  `file` varchar(100) NOT NULL default '',
  PRIMARY KEY  (`caduc`),
  KEY `ip` (`ip`),
  KEY `file` (`file`)
) TYPE=MyISAM;

this is working good in my site

Aniceto Lopez
http://www.lamundial.net
download and spread our music


-- 
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] session variables in functions....

2001-11-20 Thread wim van houts

Somebody knows why I cannot reach the $HTTP_SESSION_VARS in a function 

For example, why does this not output the "en-US" string three times:





-- 
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] Session variables and register_global

2001-04-04 Thread Niklas Neumann

Hello,

is it meant that

session_register("test");
$GLOBALS['HTTP_SESSION_VARS']['test'] = 'Hello World!';

does not work properly (session variable test is not initialized with the 
value 'Hello World!') if register_globals is turned on, but when it is 
turned off?

Best regards
  Niklas 

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




Re: [PHP] session variables - help

2009-08-13 Thread Ben Dunlap
>
> I have the following code for order_update.php:
>
> [code]
>
> session_start();
> extract($_POST);
> foreach ($_POST as $var => $val) {
>  if ($val > 0) {
>  $_SESSION[$var] = $val;
>  } else {
>  unset($var);
>
>  }
>  header("Location: order_process.php");
> }
>
> [/code]
>
> This is not working, however, and it just loads order_process.php with no
> values for the varaibles, as if I just refreshed the page with no sessions.


Maybe you left it out but I didn't see any place where you used $_SESSION in
order_process.php. Also, your redirect in order_update.php appears to be
inside your foreach loop, which would definitely mess things right up -- but
maybe that was just a typo in your email?

Otherwise the logic in order_update.php looks OK, but there are a few side
notes that jumped out:

1. I'm not seeing why you used "extract($_POST)" in order_update.php. Right
after the extract() call, you iterate through $_POST with a foreach loop, so
what's the purpose of calling extract()? Is there more code that you left
out?

2. Calling "extract($_POST)" is dangerous. The PHP manual warns against it,
although without giving much of an explanation:

http://us2.php.net/manual/en/function.extract.php

Apart from making it difficult to filter the input you're expecting to see,
"extract($_POST)" also allows a malicious end-user to define any variable of
his choosing and to overwrite any variables that you may have defined in the
script before the extract() call.

I like to use filter_input() to read the values of POST variables.

By much the same token, you'll want to escape $a, etc., in your
writeResultRow() function, with something like htmlentities().

3. Why the "unset($var)" in order_update.php? $var already gets reset each
time foreach iterates. So, calling unset() on it at the end of the loop
doesn't really do much. I'm wondering what you were aiming at there.

Thanks,

Ben


Re: [PHP] session variables - help

2009-08-13 Thread Allen McCabe
Ben,

First of all, I thank you for your time and help.

My ai with using unset($var) in update_order.php is to set the SESSION
variable for an item to ' ' (empty) so that it would not show up on the
order summary (because my writeResultRow() function will only write a row if
that variable is greater than 0).

I just can't figure out what I'm missing here. Before I received your
response, I made a few changes to my code, which helped streamline the
calculating parts (grabbing values from SESSION instead of POST, and now
when I update order_summary, the values will remain because it pulls them
from the SESSION).

I want to edit the values in the SESSION, so that when update_order.php
redirects to order_process.php, the values are changed, and if applicable,
an item is removed from the html table (if the quantity is less than 1).

Here is some more complete code:

[code = order_process.php]

$v) {
 $_SESSION[$k]=$v;
}

$thisPage="AFY";  //NAVIGATION PURPOSES
include("afyshows.php"); //CONTAINS ARRAYS FOR SHOW ENTITIES; POPULATES
ORDER FORM
?>

. . .


 
 
 
 
 
 
 
 
 
 
 
. . .

\n\t";
  echo "".$b."".$c."".$d."";
  echo "".$e." =\$".$f."";
  echo "";
 }
}

//SETS $Total_show_01 to PRICE * QUANTITY
//FORMATS TOTAL
//IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES
$Total_show_01 = findTotalCost($shows['show_01']['price'],
$_SESSION['show_01_qty']);
$Total_show_01_fmtd = number_format($Total_show_01, 2, '.', '');
writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'],
$shows['show_01']['date'], $shows['show_01']['time'],
$shows['show_01']['price'],$Total_show_01_fmtd);

//ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38)

?>
. . .



[/code]

Now, here is the update_order.php code in entirety:

[code]

 $val) {
 if ($val == "0") {
  unset($_SESSION[$var]);
 } elseif ($val == '') {
  unset($_SESSION[$var]);
 } else {
  $val = $_SESSION[$var];

 }
}
header("Location: order_process.php");

//NOTICE I FIXED THE LOCATION OF THE header() FUNCTION
//BUT IT STILL DOES NOT UPDATE

?>

[/code]

If you're still with me, I thank you. I removed all the styling elements
from the html to make it easier for you (and me) to see what it says. I have
invested many hours into this, and have generated many many lines of code,
but I hope what I gave you is sufficient, while not being overwhelming at
this hour.

Thank you very much for your help thus far, anything else would be greatly
appreciated.


On Thu, Aug 13, 2009 at 5:56 PM, Ben Dunlap wrote:

>
>
>> I have the following code for order_update.php:
>>
>> [code]
>>
>> session_start();
>> extract($_POST);
>> foreach ($_POST as $var => $val) {
>>  if ($val > 0) {
>>  $_SESSION[$var] = $val;
>>  } else {
>>  unset($var);
>>
>>  }
>>  header("Location: order_process.php");
>> }
>>
>> [/code]
>>
>> This is not working, however, and it just loads order_process.php with no
>> values for the varaibles, as if I just refreshed the page with no
>> sessions.
>
>
> Maybe you left it out but I didn't see any place where you used $_SESSION
> in order_process.php. Also, your redirect in order_update.php appears to be
> inside your foreach loop, which would definitely mess things right up -- but
> maybe that was just a typo in your email?
>
> Otherwise the logic in order_update.php looks OK, but there are a few side
> notes that jumped out:
>
> 1. I'm not seeing why you used "extract($_POST)" in order_update.php. Right
> after the extract() call, you iterate through $_POST with a foreach loop, so
> what's the purpose of calling extract()? Is there more code that you left
> out?
>
> 2. Calling "extract($_POST)" is dangerous. The PHP manual warns against it,
> although without giving much of an explanation:
>
> http://us2.php.net/manual/en/function.extract.php
>
> Apart from making it difficult to filter the input you're expecting to see,
> "extract($_POST)" also allows a malicious end-user to define any variable of
> his choosing and to overwrite any variables that you may have defined in the
> script before the extract() call.
>
> I like to use filter_input() to read the values of POST variables.
>
> By much the same token, you'll want to escape $a, etc., in your
> writeResultRow() function, with something like htmlentities().
>
> 3. Why the "unset($var)" in order_update.php? $var already gets reset each
> time foreach iterates. So, calling unset() on it at the end of the loop
> doesn't really do much. I'm wondering what you were aiming at there.
>
> Thanks,
>
> Ben
>
>


Re: [PHP] session variables - help

2009-08-14 Thread Ralph Deffke
I'm realy sorry for u, but the reason for no answers is ur concept.

may be some rules will help u and I recommend u to think to spend the time
to rewrite the whole code. Im shure u will solve the problem then:
first  dont use the global arrays directly. pick the values u need and put
them in reasonable types of variables.
build the business logic on these variables and if u feel like put the
results in well readable new ones
then populate the presentation in the required htmls
this will give u an more structured code, easier to debug and more fun for
the group to help u

I still dont understand why u use the $_SESSION variable. user often leave
forms open for hours and then submit them. u can not expect a user to end a
job in the livecycle of the session. thats what hidden form fields are made
for.

the $_session is for member like things and applications with security
issues where u can expect the user to finish things in a certain time or u
restart the whole.

"Allen McCabe"  wrote in message
news:657acef20908132257x630719e1g4ecddcdff9492...@mail.gmail.com...
> Ben,
>
> First of all, I thank you for your time and help.
>
> My ai with using unset($var) in update_order.php is to set the SESSION
> variable for an item to ' ' (empty) so that it would not show up on the
> order summary (because my writeResultRow() function will only write a row
if
> that variable is greater than 0).
>
> I just can't figure out what I'm missing here. Before I received your
> response, I made a few changes to my code, which helped streamline the
> calculating parts (grabbing values from SESSION instead of POST, and now
> when I update order_summary, the values will remain because it pulls them
> from the SESSION).
>
> I want to edit the values in the SESSION, so that when update_order.php
> redirects to order_process.php, the values are changed, and if applicable,
> an item is removed from the html table (if the quantity is less than 1).
>
> Here is some more complete code:
>
> [code = order_process.php]
>
>  session_start();
> // POST ALL $_POST VALUES, CREATE AS VARIABLES IN SESSION
> foreach($_POST as $k=>$v) {
>  $_SESSION[$k]=$v;
> }
>
> $thisPage="AFY";  //NAVIGATION PURPOSES
> include("afyshows.php"); //CONTAINS ARRAYS FOR SHOW ENTITIES; POPULATES
> ORDER FORM
> ?>
>
> . . .
>
> 
>  
>  
>  
>  
>  
>  
>  
>  
>  
>   />
>  
> . . .
>
> 
> function findTotalCost($b, $c) {
>  $total = $b * $c;
>  return $total;
> }
>
> function writeResultRow($a, $b, $c, $d, $e, $f) {
>  if($a != '') {
>   echo "\n\n\t";
>   echo "".$b."".$c."".$d."";
>   echo "".$e."  name='".$a."' id='".$a."' size='2' />=\$".$f."";
>   echo "";
>  }
> }
>
> //SETS $Total_show_01 to PRICE * QUANTITY
> //FORMATS TOTAL
> //IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES
> $Total_show_01 = findTotalCost($shows['show_01']['price'],
> $_SESSION['show_01_qty']);
> $Total_show_01_fmtd = number_format($Total_show_01, 2, '.', '');
> writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'],
> $shows['show_01']['date'], $shows['show_01']['time'],
> $shows['show_01']['price'],$Total_show_01_fmtd);
>
> //ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38)
>
> ?>
> . . .
>
> 
>
> [/code]
>
> Now, here is the update_order.php code in entirety:
>
> [code]
>
>  session_start();
> foreach ($_SESSION as $var => $val) {
>  if ($val == "0") {
>   unset($_SESSION[$var]);
>  } elseif ($val == '') {
>   unset($_SESSION[$var]);
>  } else {
>   $val = $_SESSION[$var];
>
>  }
> }
> header("Location: order_process.php");
>
> //NOTICE I FIXED THE LOCATION OF THE header() FUNCTION
> //BUT IT STILL DOES NOT UPDATE
>
> ?>
>
> [/code]
>
> If you're still with me, I thank you. I removed all the styling elements
> from the html to make it easier for you (and me) to see what it says. I
have
> invested many hours into this, and have generated many many lines of code,
> but I hope what I gave you is sufficient, while not being overwhelming at
> this hour.
>
> Thank you very much for your help thus far, anything else would be greatly
> appreciated.
>
>
> On Thu, Aug 13, 2009 at 5:56 PM, Ben Dunlap
wrote:
>
> >
> >
> >> I have the following code for order_update.php:
> >>
> >> [code]
> >>
> >> session_start();
> >> extract($_POST);
> >> foreach ($_POST as $var => $val) {
> >>  if ($val > 0) {
> >>  $_SESSION[$var] = $val;
> >>  } else {
> >>  unset($var);
> >>
> >>  }
> >>  header("Location: order_process.php");
> >> }
> >>
> >> [/code]
> >>
> >> This is not working, however, and it just loads order_process.php with
no
> >> values for the varaibles, as if I just refreshed the page with no
> >> sessions.
> >
> >
> > Maybe you left it out but I didn't see any place where you used
$_SESSION
> > in order_process.php. Also, your redirect in order_update.php appears to
be
> > inside your foreach loop, which would definitely mess things right up -- 
but
> > maybe that was just a typo in your email?
> >
> > Otherwise the logic in order_update.php looks OK, but th

Re: [PHP] session variables - help

2009-08-14 Thread Ashley Sheridan
On Fri, 2009-08-14 at 09:55 +0200, Ralph Deffke wrote:
> user often leave
> forms open for hours and then submit them

These users should be taken out and beaten over the head with their
keyboards!

Thanks,
Ash
http://www.ashleysheridan.co.uk


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



Re: [PHP] session variables - help

2009-08-14 Thread Ralph Deffke
well thanks good they are far away then, but the problem is ur client, i
didnt find anybody giving me the permission to beat his customers

"Ashley Sheridan"  wrote in message
news:1250236989.2344.10.ca...@localhost...
> On Fri, 2009-08-14 at 09:55 +0200, Ralph Deffke wrote:
> > user often leave
> > forms open for hours and then submit them
>
> These users should be taken out and beaten over the head with their
> keyboards!
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>



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



Re: [PHP] session variables - help

2009-08-14 Thread Ashley Sheridan
On Fri, 2009-08-14 at 10:05 +0200, Ralph Deffke wrote:
> well thanks good they are far away then, but the problem is ur client, i
> didnt find anybody giving me the permission to beat his customers
> 
> "Ashley Sheridan"  wrote in message
> news:1250236989.2344.10.ca...@localhost...
> > On Fri, 2009-08-14 at 09:55 +0200, Ralph Deffke wrote:
> > > user often leave
> > > forms open for hours and then submit them
> >
> > These users should be taken out and beaten over the head with their
> > keyboards!
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> 
> 
> 

Beat them hard enough and they tend to forget who did it...

My life would be so much easier without end users!

Thanks,
Ash
http://www.ashleysheridan.co.uk


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



RE: [PHP] session variables - help

2009-08-14 Thread Ford, Mike
> -Original Message-
> From: Allen McCabe [mailto:allenmcc...@gmail.com]
> Sent: 14 August 2009 06:58

 
> My ai with using unset($var) in update_order.php is to set the
> SESSION
> variable for an item to ' ' (empty) so that it would not show up on
> the
> order summary (because my writeResultRow() function will only write
> a row if
> that variable is greater than 0).
> 
> I just can't figure out what I'm missing here. Before I received
> your
> response, I made a few changes to my code, which helped streamline
> the
> calculating parts (grabbing values from SESSION instead of POST, and
> now
> when I update order_summary, the values will remain because it pulls
> them
> from the SESSION).
> 
> I want to edit the values in the SESSION, so that when
> update_order.php
> redirects to order_process.php, the values are changed, and if
> applicable,
> an item is removed from the html table (if the quantity is less than
> 1).
> 
> Here is some more complete code:
> 
> [code = order_process.php]
> 
>  session_start();
> // POST ALL $_POST VALUES, CREATE AS VARIABLES IN SESSION
> foreach($_POST as $k=>$v) {
>  $_SESSION[$k]=$v;
> }

This has just destroyed anything that was previously in the session, so if 
you're recycling from the update_order.php script, you've just thrown away 
whatever that script did!  You need to make this conditional on having arrived 
here from the initial form -- various ways you could do that, but I leave you 
to figure that one out.

(Also, personally, if I were doing this at all, I would just copy the array as 
a single entity:

$_SESSION['_POST'] = $_POST;

and then reference individual elements through that as, e.g., 
$_SESSION['_POST']['School']. That's probably a matter of personal style as 
much as anything, but gives you another way to think about.)


[ . . . . ]


> 
>  
> function findTotalCost($b, $c) {
>  $total = $b * $c;
>  return $total;
> }
> 
> function writeResultRow($a, $b, $c, $d, $e, $f) {
>  if($a != '') {
>   echo "\n\n\t";
>   echo "".$b."".$c."".$d."";
>   echo "".$e."  value='".$a."'
> name='".$a."' id='".$a."' size='2'
> />=\$".$f."";
>   echo "";
>  }
> }
> 
> //SETS $Total_show_01 to PRICE * QUANTITY
> //FORMATS TOTAL
> //IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES
> $Total_show_01 = findTotalCost($shows['show_01']['price'],
> $_SESSION['show_01_qty']);
> $Total_show_01_fmtd = number_format($Total_show_01, 2, '.', '');
> writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'],
> $shows['show_01']['date'], $shows['show_01']['time'],
> $shows['show_01']['price'],$Total_show_01_fmtd);
> 
> //ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38)

AARRRGHHH!!

This cries out for an array-based solution -- repeating near-identical code 
that many times is totally ludicrous, and should be a major clue that you need 
to refactor.  You'll have to forgo using indexes like ['show_01'] and use 
straight integers, but the massive reduction in repetitive code (and hence far 
fewer opportunities for mistakes!) will be well worth it.

Something like:

   for ($i=1; $i<=38; ++$i):
  $Total[$i] = findTotalCost($shows[$i]['price'], $_SESSION['qty'][$i]);
  $Total_fmtd[$i] = number_format($Total[$i], 2, '.', '');
  writeResultRow($_SESSION['qty'][$i], $shows[$i]['title'], 
$shows[$i]['date'], $shows[$i]['time'], $shows[$i]['price'],$Total_fmtd[$i]);
   endfor;

[ . . . . ]
 
> Now, here is the update_order.php code in entirety:
> 
> [code]
> 
>  session_start();
> foreach ($_SESSION as $var => $val) {
>  if ($val == "0") {
>   unset($_SESSION[$var]);
>  } elseif ($val == '') {
>   unset($_SESSION[$var]);
>  } else {
>   $val = $_SESSION[$var];

That line is back-to-front -- you're assigning the current value in the session 
to $val, which is then immediately thrown away as the foreach loop starts a new 
iteration. What you mean is $_SESSION[$var] = $val.


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730






To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] session variables - help

2009-08-14 Thread Ford, Mike
> -Original Message-
> From: Ford, Mike [mailto:m.f...@leedsmet.ac.uk]
> Sent: 14 August 2009 11:45


> > Now, here is the update_order.php code in entirety:
> >
> > [code]
> >
> >  > session_start();
> > foreach ($_SESSION as $var => $val) {
> >  if ($val == "0") {
> >   unset($_SESSION[$var]);
> >  } elseif ($val == '') {
> >   unset($_SESSION[$var]);
> >  } else {
> >   $val = $_SESSION[$var];
> 
> That line is back-to-front -- you're assigning the current value in
> the session to $val, which is then immediately thrown away as the
> foreach loop starts a new iteration. What you mean is
> $_SESSION[$var] = $val.

No, wait a minute, hold your foot up!  I was so focussed on the strange 
assignment that I didn't read the whole thing properly.  What you're *actually* 
doing here is -- er, well, totally not what you want to, I suspect! Having 
re-read the message I responded to, I'm going to go back to it and post another 
response


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] session variables - help

2009-08-14 Thread Ford, Mike
> -Original Message-
> From: Allen McCabe [mailto:allenmcc...@gmail.com]
> Sent: 14 August 2009 06:58
> 
> Here is some more complete code:
> 
> [code = order_process.php]
> 
>  session_start();
> // POST ALL $_POST VALUES, CREATE AS VARIABLES IN SESSION
> foreach($_POST as $k=>$v) {
>  $_SESSION[$k]=$v;
> }
> 
> $thisPage="AFY";  //NAVIGATION PURPOSES
> include("afyshows.php"); //CONTAINS ARRAYS FOR SHOW ENTITIES;
> POPULATES
> ORDER FORM
> ?>
> 
> . . .
> 
> 
>  

Er wait, no! Sessions and hidden form fields are generally alternative 
solutions to the same problem -- you shouldn't be putting the same values both 
in the session and in hidden form fields.  In this case, I'm beginning to 
suspect that the hidden fields are the better solution, but there is a certain 
amount of personal preference in this.

>  
>  
>  
>  
>  
>  
>  
>  
>   />
>  
> . . .
> 
>  
> function findTotalCost($b, $c) {
>  $total = $b * $c;
>  return $total;
> }
> 
> function writeResultRow($a, $b, $c, $d, $e, $f) {
>  if($a != '') {
>   echo "\n\n\t";
>   echo "".$b."".$c."".$d."";
>   echo "".$e."  value='".$a."'
> name='".$a."' id='".$a."' size='2'
> />=\$".$f."";
>   echo "";
>  }
> }
> 
> //SETS $Total_show_01 to PRICE * QUANTITY
> //FORMATS TOTAL
> //IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES
> $Total_show_01 = findTotalCost($shows['show_01']['price'],
> $_SESSION['show_01_qty']);
> $Total_show_01_fmtd = number_format($Total_show_01, 2, '.', '');
> writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'],
> $shows['show_01']['date'], $shows['show_01']['time'],
> $shows['show_01']['price'],$Total_show_01_fmtd);
> 
> //ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38)
> 
> ?>
> . . .
> 
> 
> 
> [/code]

If I'm reading what you want to do correctly, it seems to me there are two 
obvious approaches to this:

(i) Have a single form which posts back to itself, showing all the show 
information and requested quantities and calculated result fields (such as 
total cost); initially, this will have the calculated fields not displaying 
anything, and these will be (re)populated at each Update.  Using this method, 
all your values are contained solely within the $_POST array.

(ii) Have your initial form post to the process form, which then also posts to 
itself on Update. This process form will have visible fields only for values 
which can be changed, but *must* then contain hidden fields for all the other 
values which were originally passed in the $_POST array.  This arrangement 
means that the process form always receives a full complement of values in the 
$_POST array -- either from the original form, or from hidden fields posted 
back to itself.

This is all just coming off the top of my head, and I'm sure there are 
improvements/other solutions to be offered.  Hope this will give you some 
things to think about, and maybe a pointer or two towards a satisfactory 
solution.


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] session variables - help

2009-08-14 Thread Allen McCabe
Thank you all for your responses.

Mike.

I like the ii option better, mostly because I already have most of that in
place (ie. order posts to process, and process has editable fields and
hidden fields with the remaining complimentary values).
Martin suggested I use the following code for my update script (which is
posted to via the process page):

[code]

foreach($_POST as $key => $value)
if( '0' == $value || '' == $value )
{
/*if*/ session_is_registered( $key ) &&
session_unregister( $key );
}

[/code]

I am not following the logic on the above code very well, but is this indeed
a better option? And is not session_*whatever deprecated? The reason I am
using $_SESSION is because it seems that php 6 will use solely this method,
and it currently works with php 5. The other reason I am using it is so that
I can keep the variables stored elsewhere for whenever I need them; I don't
want to have to juggle all the information with POST and hidden inputs
unless it will work seamlessly, and be ready for update at a later date (if
I move to using a database to store show information, or when php 6 is
mainstream).

Keep in mind that once I get the update feature working, I need the process
page to have a final submit button that will insert the order into a
database table AND send a notification email to myself (and an email to the
user). Am I setting myself up for failure with this udate order option? I
ask because the update feature relies on a form, and are not forms limited
to one submit button?

Thanks all for your patience! I will work on this today and write back with
any further questions I can't figure out on my own. And if anyone has any
advice I will be checking my email regularly.

Allen
On Fri, Aug 14, 2009 at 7:52 AM, Ford, Mike  wrote:

> > -Original Message-
> > From: Allen McCabe [mailto:allenmcc...@gmail.com]
> > Sent: 14 August 2009 06:58
> >
> > Here is some more complete code:
> >
> > [code = order_process.php]
> >
> >  > session_start();
> > // POST ALL $_POST VALUES, CREATE AS VARIABLES IN SESSION
> > foreach($_POST as $k=>$v) {
> >  $_SESSION[$k]=$v;
> > }
> >
> > $thisPage="AFY";  //NAVIGATION PURPOSES
> > include("afyshows.php"); //CONTAINS ARRAYS FOR SHOW ENTITIES;
> > POPULATES
> > ORDER FORM
> > ?>
> >
> > . . .
> >
> > 
> >  
>
> Er wait, no! Sessions and hidden form fields are generally alternative
> solutions to the same problem -- you shouldn't be putting the same values
> both in the session and in hidden form fields.  In this case, I'm beginning
> to suspect that the hidden fields are the better solution, but there is a
> certain amount of personal preference in this.
>
> >  
> >  
> >  
> >  
> >  
> >  
> >  
> >  
> >   > />
> >  
> > . . .
> >
> >  >
> > function findTotalCost($b, $c) {
> >  $total = $b * $c;
> >  return $total;
> > }
> >
> > function writeResultRow($a, $b, $c, $d, $e, $f) {
> >  if($a != '') {
> >   echo "\n\n\t";
> >   echo "".$b."".$c."".$d."";
> >   echo "".$e."  > value='".$a."'
> > name='".$a."' id='".$a."' size='2'
> > />=\$".$f."";
> >   echo "";
> >  }
> > }
> >
> > //SETS $Total_show_01 to PRICE * QUANTITY
> > //FORMATS TOTAL
> > //IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES
> > $Total_show_01 = findTotalCost($shows['show_01']['price'],
> > $_SESSION['show_01_qty']);
> > $Total_show_01_fmtd = number_format($Total_show_01, 2, '.', '');
> > writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'],
> > $shows['show_01']['date'], $shows['show_01']['time'],
> > $shows['show_01']['price'],$Total_show_01_fmtd);
> >
> > //ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38)
> >
> > ?>
> > . . .
> >
> > 
> >
> > [/code]
>
> If I'm reading what you want to do correctly, it seems to me there are two
> obvious approaches to this:
>
> (i) Have a single form which posts back to itself, showing all the show
> information and requested quantities and calculated result fields (such as
> total cost); initially, this will have the calculated fields not displaying
> anything, and these will be (re)populated at each Update.  Using this
> method, all your values are contained solely within the $_POST array.
>
> (ii) Have your initial form post to the process form, which then also posts
> to itself on Update. This process form will have visible fields only for
> values which can be changed, but *must* then contain hidden fields for all
> the other values which were originally passed in the $_POST array.  This
> arrangement means that the process form always receives a full complement of
> values in the $_POST array -- either from the original form, or from hidden
> fields posted back to itself.
>
> This is all just coming off the top of my head, and I'm sure there are
> improvements/other solutions to be offered.  Hope this will give you some
> things to think about, and maybe a pointer or two towards a satisfactory
> solution.
>
>
> Cheers!
>
> Mike
>  --
> Mike Ford,
> Electronic Information D

Re: [PHP] session variables - help

2009-08-14 Thread Martin Scotta
On Fri, Aug 14, 2009 at 12:25 PM, Allen McCabe wrote:

> Thank you all for your responses.
>
> Mike.
>
> I like the ii option better, mostly because I already have most of that in
> place (ie. order posts to process, and process has editable fields and
> hidden fields with the remaining complimentary values).
> Martin suggested I use the following code for my update script (which is
> posted to via the process page):
>
> [code]
>
> foreach($_POST as $key => $value)
>if( '0' == $value || '' == $value )
>{
>/*if*/ session_is_registered( $key ) &&
>session_unregister( $key );
>}
>
> [/code]
>
> I am not following the logic on the above code very well, but is this
> indeed
> a better option? And is not session_*whatever deprecated? The reason I am
> using $_SESSION is because it seems that php 6 will use solely this method,
> and it currently works with php 5. The other reason I am using it is so
> that
> I can keep the variables stored elsewhere for whenever I need them; I don't
> want to have to juggle all the information with POST and hidden inputs
> unless it will work seamlessly, and be ready for update at a later date (if
> I move to using a database to store show information, or when php 6 is
> mainstream).
>
> Keep in mind that once I get the update feature working, I need the process
> page to have a final submit button that will insert the order into a
> database table AND send a notification email to myself (and an email to the
> user). Am I setting myself up for failure with this udate order option? I
> ask because the update feature relies on a form, and are not forms limited
> to one submit button?
>
> Thanks all for your patience! I will work on this today and write back with
> any further questions I can't figure out on my own. And if anyone has any
> advice I will be checking my email regularly.
>
> Allen
> On Fri, Aug 14, 2009 at 7:52 AM, Ford, Mike  wrote:
>
> > > -Original Message-
> > > From: Allen McCabe [mailto:allenmcc...@gmail.com]
> > > Sent: 14 August 2009 06:58
> > >
> > > Here is some more complete code:
> > >
> > > [code = order_process.php]
> > >
> > >  > > session_start();
> > > // POST ALL $_POST VALUES, CREATE AS VARIABLES IN SESSION
> > > foreach($_POST as $k=>$v) {
> > >  $_SESSION[$k]=$v;
> > > }
> > >
> > > $thisPage="AFY";  //NAVIGATION PURPOSES
> > > include("afyshows.php"); //CONTAINS ARRAYS FOR SHOW ENTITIES;
> > > POPULATES
> > > ORDER FORM
> > > ?>
> > >
> > > . . .
> > >
> > > 
> > >  
> >
> > Er wait, no! Sessions and hidden form fields are generally alternative
> > solutions to the same problem -- you shouldn't be putting the same values
> > both in the session and in hidden form fields.  In this case, I'm
> beginning
> > to suspect that the hidden fields are the better solution, but there is a
> > certain amount of personal preference in this.
> >
> > >  
> > >  
> > >  
> > >  
> > >  
> > >  
> > >  
> > >  
> > >   > > />
> > >  
> > > . . .
> > >
> > >  > >
> > > function findTotalCost($b, $c) {
> > >  $total = $b * $c;
> > >  return $total;
> > > }
> > >
> > > function writeResultRow($a, $b, $c, $d, $e, $f) {
> > >  if($a != '') {
> > >   echo "\n\n\t";
> > >   echo "".$b."".$c."".$d."";
> > >   echo "".$e."  > > value='".$a."'
> > > name='".$a."' id='".$a."' size='2'
> > > />=\$".$f."";
> > >   echo "";
> > >  }
> > > }
> > >
> > > //SETS $Total_show_01 to PRICE * QUANTITY
> > > //FORMATS TOTAL
> > > //IF A QUANTITY IS ENTERED, WRITES THE ROW WITH CURRENT VARIABLES
> > > $Total_show_01 = findTotalCost($shows['show_01']['price'],
> > > $_SESSION['show_01_qty']);
> > > $Total_show_01_fmtd = number_format($Total_show_01, 2, '.', '');
> > > writeResultRow($_SESSION['show_01_qty'], $shows['show_01']['title'],
> > > $shows['show_01']['date'], $shows['show_01']['time'],
> > > $shows['show_01']['price'],$Total_show_01_fmtd);
> > >
> > > //ABOVE LINES REPEATED FOR ALL 38 ENTITIES (show_01 to show_38)
> > >
> > > ?>
> > > . . .
> > >
> > > 
> > >
> > > [/code]
> >
> > If I'm reading what you want to do correctly, it seems to me there are
> two
> > obvious approaches to this:
> >
> > (i) Have a single form which posts back to itself, showing all the show
> > information and requested quantities and calculated result fields (such
> as
> > total cost); initially, this will have the calculated fields not
> displaying
> > anything, and these will be (re)populated at each Update.  Using this
> > method, all your values are contained solely within the $_POST array.
> >
> > (ii) Have your initial form post to the process form, which then also
> posts
> > to itself on Update. This process form will have visible fields only for
> > values which can be changed, but *must* then contain hidden fields for
> all
> > the other values which were originally passed in the $_POST array.  This
> > arrangement means that the process form always receives a full complement
> of
> > values in the $_POST array -- either from the original form, or from
>

Re: [PHP] session variables - help

2009-08-14 Thread Ben Dunlap
> Thanks all for your patience! I will work on this today and write back with
> any further questions I can't figure out on my own. And if anyone has any
> advice I will be checking my email regularly.

If you've already tried this with no luck, please ignore -- but you
might speed up the whole process by stepping aside from the "real"
code briefly, starting fresh in an empty directory, and just putting
together a handful of extremely simple scripts with the single goal of
entering one value, updating it, and then doing some final
pseudo-processing on the updated value.

Then, you could step it up a bit by by adding a second value that gets
entered at the beginning, and cannot be updated in the middle but must
be preserved through to the end.

Doing all this might help clarify the basic flow of the system and
enable you to simplify its structure before going back and tackling
the real code.

Ben

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



[PHP] session variables in tmp

2010-06-04 Thread Stephen Sunderlin
trying out a CentOS release 5.2 (Final) V4_1_0  on AWS.  Was working 
fine and now it seems that php has stopped writing any session variable 
to /tmp.  I was cleaning up the user table in mysql and limiting 
permissions.   Not sure that this would have anything to do with it.  
Restarted apache/mysql.  tmp is  set to drwxrwxrwt  4 root root  4096 
Jun  5 00:46 tmp

PHP 5.2.4
MySQL 5.0.45
any thought on where else to look.

Thanks.

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



Re: [PHP] PHP session variables

2012-08-08 Thread Daniel Brown
On Wed, Aug 8, 2012 at 11:24 AM, Ansry User 01  wrote:
> I am setting the _SESSION variables in one of my file, but whenever I leave 
> the php page session variables are not accessible. Not sure what I need to do 
> additionally other then defining _SESSION[].
> Any pointer.

If you're not telling PHP (in php.ini) to auto-start the session,
then you'll need session_start() before accessing $_SESSION.  If
you're certain the session is being properly instantiated in the code,
make sure that the user as which the web server (Apache, et al) is
running has permission and available disk space to access the session
storage media (file system such as /tmp, database table, et cetera).

-- 

Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] PHP session variables

2012-08-08 Thread David Harkness
On Wed, Aug 8, 2012 at 8:24 AM, Ansry User 01 wrote:

> I am setting the _SESSION variables in one of my file, but whenever I
> leave the php page session variables are not accessible.


As always, post some code demonstrating what you're doing. Help us help
you! :)

David


RE: [PHP] PHP session variables

2012-08-08 Thread Jen Rasmussen
-Original Message-
From: David Harkness [mailto:davi...@highgearmedia.com] 
Sent: Wednesday, August 08, 2012 11:53 AM
To: Ansry User 01
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP session variables

On Wed, Aug 8, 2012 at 8:24 AM, Ansry User 01 wrote:

> I am setting the _SESSION variables in one of my file, but whenever I 
> leave the php page session variables are not accessible.


As always, post some code demonstrating what you're doing. Help us help you!
:)

David

You have to set session_start also on the page where you are trying to
retrieve the session variables.

Jen



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



  1   2   3   >