473,378 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

creating a session variable on every page

Hi,

I'm using PHP 4.4.4 with Apache 2.2. What I want is that if a
customer visits any page of the top level directory of my site with
this string passed in the URL's query string, "RID=xxx", I would like
a session variable called "RID" with the value "xxx" to be created.
However, I would like to avoid putting this code

session_start();
if (!empty($_REQUEST['RID'])) {
$_SESSION['RID'] = trim(strtoupper($_REQUEST['RID']));
} // if

on every page in my top level directory. Does anyone know a more
efficient way?

Thanks, - Dave

May 23 '07 #1
2 1604
On Wed, 23 May 2007 14:43:24 -0700, la***********@zipmail.com wrote:
Hi,

I'm using PHP 4.4.4 with Apache 2.2. What I want is that if a customer
visits any page of the top level directory of my site with this string
passed in the URL's query string, "RID=xxx", I would like a session
variable called "RID" with the value "xxx" to be created. However, I
would like to avoid putting this code

session_start();
if (!empty($_REQUEST['RID'])) {
$_SESSION['RID'] = trim(strtoupper($_REQUEST['RID']));
} // if

on every page in my top level directory. Does anyone know a more
efficient way?

Thanks, - Dave
Read up on require_once.
May 23 '07 #2
la***********@zipmail.com wrote:
Hi,

I'm using PHP 4.4.4 with Apache 2.2. What I want is that if a
customer visits any page of the top level directory of my site with
this string passed in the URL's query string, "RID=xxx", I would like
a session variable called "RID" with the value "xxx" to be created.
However, I would like to avoid putting this code

session_start();
if (!empty($_REQUEST['RID'])) {
$_SESSION['RID'] = trim(strtoupper($_REQUEST['RID']));
} // if

on every page in my top level directory. Does anyone know a more
efficient way?

Thanks, - Dave

Two things:

1. There is an Apache auto_prepend directive you can put in htaccess (or
httpd.conf).

2. Use mod_rewrite to redirect certain?/all? files to a script that does
your session check and then includes the requested file

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*****************************
May 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
1
by: Ann Leland | last post by:
I have been using session variables to pass a user name from one ASP page to another inside framesets for 9 months and it stopped working this week. I have made no code changes but there was a...
1
by: Dan King | last post by:
At a summary page, I am trying to clean up Session.Contents so the user can go back to the main page and not retain any unnecessary info. I have entered this into my summary page, but it seems to...
1
by: farooqazeem | last post by:
Hi guys, I’m facing some problem can u solve it. Problem is: I’m giving user Id and password in (Login_sess.asp) and submit it to page (sess_test.asp). I am setting session variable...
9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
5
by: ASP.Confused | last post by:
As you can tell from my previous posts on this issue...I'm really confused :-/ I have a few ASP.NET web applications on my web host's "https" server. Our web host has a single "bin" folder for...
4
by: T Ralya | last post by:
I am told that ASP.NET controls the session ID and session variables, but that does not fit my symptoms. I am posting here as directed. I'm hoping that someone can at least recommend something to...
14
by: Coleen | last post by:
Hi All :-) We have an APSX application using VB.net as the code behind, which uses one or two session variables per page. These Session variables are passed to the final page and calculations...
0
by: Tarun Mistry | last post by:
Hi all, I'm trying to create a global object that can be used anywhere in my ASP.NET (2.0) application but im having problems. I would like to run some logic every time the page is loaded,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.