473,386 Members | 1,830 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,386 software developers and data experts.

Session variables help

Hi ,

I am back with another small problem:

I want to create a session in which i want to declare a session variable. I want to use the value of that session variable on the next two pages. This is the code that i have.

1st page:
Expand|Select|Wrap|Line Numbers
  1. <?PHP
  2. session_start();
  3. session_register ("demo");
  4. if($_SERVER['HTTP_REFERER'] == "http://localhost/FAO_test/firms_WEB/Untitled-6.php")
  5.   {
  6.   $test=1;
  7.   $_SESSION["demo"]= $test;
  8.   }
  9.   ?>
  10.  
2nd page
Expand|Select|Wrap|Line Numbers
  1. <?PHP
  2. session_start();
  3. if ($_SESSION['demo']== 1)
  4.  include ("Untitled-7.php");
  5. ?>
  6.  
3rd page
Expand|Select|Wrap|Line Numbers
  1. <?PHP
  2. session_start();
  3. if ($_SESSION['demo']== 1)
  4.  include ("Untitled-7.php");
  5. ?>
But the problem is that the value of demo is not registering and i dont think the if statement in the 2nd and 3rd page is working. It displays the UNtitled-7.php even if demos value is not 1.

Please tell me what i am doing wrong??
Apr 15 '08 #1
1 1203
TheServant
1,168 Expert 1GB
You have:
Expand|Select|Wrap|Line Numbers
  1. if ($_SESSION['demo']== 1)
  2.  include ("Untitled-7.php");
Should be:
Expand|Select|Wrap|Line Numbers
  1. if ($_SESSION['demo']== 1) {
  2. include ("Untitled-7.php");
  3. }

Also is there any specific reason you are using session_register? You can just have: $_SESSION['demo'] = $test; instead of registering it and then giving it a value?
Apr 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dave Smithz | last post by:
Hi there, I have implemented a login sequence using session variables for a PHP/MySQL DB which I took over development. I read some books and this NG and it seemed straight forward. However the...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
6
by: Nedu N | last post by:
Hi, I am trying to design a Home page for my applicatiion in which i want show the links for for some itms... I tried to put the following <td> <font face="Arial, Helvetica, sans-serif" ...
3
by: bennett | last post by:
In the web.config file for my application, in the <sessionState> section I have set timeout="120" (in minutes), but session state variables in my application seem to be expiring in about 5 minutes....
10
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much...
3
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have...
18
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
22
by: K. A. | last post by:
I have two servers at work, 'A' for testing and development, and server 'B' for production. On server A, I wrote a PHP test code to login users then direct them to a personalized page. This is...
12
by: MrHelpMe | last post by:
Hello again all, I've finished my whole application and now I don't like the whole session variables that I am using. I have a form, user fills in info clicks submit and using CDOSYSMail an...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.