*

Recent

Author Topic: session variables  (Read 6846 times)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
session variables
« on: 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
« Last Edit: December 03, 2011, 07:56:52 PM by spagetiokillers »

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: session variables
« Reply #1 on: 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.

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: session variables
« Reply #2 on: 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.

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: session variables
« Reply #3 on: 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?

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: session variables
« Reply #4 on: 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

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: session variables
« Reply #5 on: 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.

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: session variables
« Reply #6 on: December 07, 2011, 09:11:18 PM »
LOL kurt i figured that out yesterday. I was like ..........

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: session variables
« Reply #7 on: 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