Welcome Guest, Not a member yet? Register   Sign In
Can't get the variable value from extended class
#10

[eluser]Paul Scott[/eluser]
This is happening because PHP variables are only kept per request.

If you want to keep a variable between requests, then you can store the value in a cookie (provided it is a simple data type; eg. string or number) or in a session. Therefore, when you set the variable in your `Globalclass`, the value is set as you would expect only for you to redirect the user to another page (the user makes a new request for the home page) and this time PHP does not set again the value for the login name.

Perhaps you are misunderstanding what the `redirect` function does, but it works the same as using `header('Location: ...');` and so creates a seperate request.


Messages In This Thread
Can't get the variable value from extended class - by El Forum - 10-27-2007, 12:18 AM
Can't get the variable value from extended class - by El Forum - 10-27-2007, 12:41 AM
Can't get the variable value from extended class - by El Forum - 10-27-2007, 12:44 AM
Can't get the variable value from extended class - by El Forum - 10-27-2007, 01:47 AM
Can't get the variable value from extended class - by El Forum - 10-27-2007, 01:52 AM
Can't get the variable value from extended class - by El Forum - 10-27-2007, 02:09 AM
Can't get the variable value from extended class - by El Forum - 10-27-2007, 05:16 AM
Can't get the variable value from extended class - by El Forum - 10-27-2007, 07:12 AM
Can't get the variable value from extended class - by El Forum - 10-27-2007, 07:23 AM
Can't get the variable value from extended class - by El Forum - 10-27-2007, 08:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB