1
tayling
adding a session variable
  • 2009/1/7 23:39

  • tayling

  • Just popping in

  • Posts: 86

  • Since: 2002/1/3 7


i would like to capture a parameter and store it into the session on startup i.e. mydomain.com/1234 where 1234 is an item number - when is the XOOPS session available?
Cheers
Tony

2
trabis
Re: adding a session variable
  • 2009/1/8 1:01

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


$_SESSION['your_var']=1234;

You can look inside include/common.php around line 263 for $sess_handler

3
tayling
Re: adding a session variable
  • 2009/1/8 22:09

  • tayling

  • Just popping in

  • Posts: 86

  • Since: 2002/1/3 7


hi
thanks for the reply - I have used $_SESSION['your_var']= 1234
and
myvar = $_SESSION['your_var'] on another page but the variable is blank - do you know how i can check the reason?
Thanks for your help

4
trabis
Re: adding a session variable
  • 2009/1/8 22:25

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


$myvar = $_SESSION['your_var'] must be after including mainfile.php.

Are you including mainfile.php in that page?

5
tayling
Re: adding a session variable
  • 2009/1/8 22:46

  • tayling

  • Just popping in

  • Posts: 86

  • Since: 2002/1/3 7


I have now tried
domainname.com/xoops/index.php?un=1234

and in index.php
$_SESSION['un'] = $_REQUEST['un']

but this does not carry into the session
any ideas?
Cheers
Tony

6
trabis
Re: adding a session variable
  • 2009/1/8 22:52

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


...

7
trabis
Re: adding a session variable
  • 2009/1/8 22:55

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

and in index.php
$_SESSION['un'] = $_REQUEST['un']


Why using that in index?
You should use it in include/common.php so it can be accessed in other pages.

8
tayling
Re: adding a session variable
  • 2009/1/8 23:01

  • tayling

  • Just popping in

  • Posts: 86

  • Since: 2002/1/3 7


thanks trabis
sounds good but i cant see how to do that - can you give me an example? am using ver 2.0.18.1 byt the way
Thanks
TOny

9
trabis
Re: adding a session variable
  • 2009/1/8 23:08

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


open common.php and paste $_SESSION['un'] = $_REQUEST['un']; right before ?>

Then you can get use $var=$_SESSION['un']; in any page that calls mainfile.php (this covers almost every page, lol)


Login

Who's Online

451 user(s) are online (348 user(s) are browsing Support Forums)


Members: 0


Guests: 451


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits