Free Arcade Script

General => General Discussion => : Dillon December 03, 2011, 07:53:51 PM

: session variables
: Dillon December 03, 2011, 07:53:51 PM
anyone know how to set a normal variable equal to a session variable i cant seem to get it to work
: Re: session variables
: Adam LaCombe December 03, 2011, 08:00:02 PM
You mean like..
$userid = $_SESSION['id'];
?

That should work. Just gotta make sure that the $_SESSION['id'] as been set to hold some sort of value first.
: Re: session variables
: Dillon December 03, 2011, 08:01:34 PM
thats exactly what i mean but yet for some reason no matter what i do it wont work.
: Re: session variables
: Dillon December 03, 2011, 08:06:01 PM
lets say i set it in index.php for FAS and then tried using it in another file it doesnt want to work but if i set it in that file then it will and i dont want to have to set it for every file or do i have to?
: Re: session variables
: Adam LaCombe December 03, 2011, 08:54:12 PM
I'll give you some examples..

file - starter.php ->
session_start(); ->
$var = $_SESSION['blah'] ->
file - test.php ->
echo - $var

^^ thats not going to work.

file - starter.php ->
session_start() ->
$var = $_SESSION['blah'] ->
file - test.php ->
include('starter.php');
echo - $var

^^ that will work.

So set the var..
Then if you're using the index.php file add another case inside your switch().
Access the file where you try to echo the session var out by using index.php?action=case_name
: Re: session variables
: kurt December 07, 2011, 06:49:19 PM
You may also be running into the problem that it needs to be set as a global variable in any function, and again in any function declared inside that function, or passed to that function. If not, the script don't see it.
: Re: session variables
: Dillon December 07, 2011, 09:11:18 PM
LOL kurt i figured that out yesterday. I was like ..........
: Re: session variables
: kurt December 09, 2011, 07:02:52 PM
If you figured it out already, then you're quicker than me. I still forget lol.

Hey, I keep saying that we don't claim to be professional grade around here, just trying our best. ROTFL
TinyPortal © 2005-2012