473,320 Members | 2,202 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,320 software developers and data experts.

Session variables not working in PHP 5.0.4

Hi All,
I have a web site which was hosted on m/c A and PHP version there was 4.4.3
Now I have moved my website to m/c B and the PHP version is 5.0.4
But now the problem is that the on the m/c B my session variables(HTTP session variables) used in the PHP code are not maintained across all the pages which is creating problem on my website.
I have put the exact code in m/c B which was there in m/c A and was working perfectly.

Am I missing here??
I am not sure but do I ned to make any changes in my ini file on m/c B?

Please Help.

Regards,
Hussain
Nov 15 '07 #1
4 4076
Atli
5,058 Expert 4TB
Hi Hussain.

Could you show us how the code you use to create and use your session variables?
Nov 16 '07 #2
Expand|Select|Wrap|Line Numbers
  1. <?
  2. //first page
  3. session_start();
  4. session_register('variable');
  5.  
  6. $HTTP_SESSION_VARS['variable']= value;
  7. ?>
  8. <html>
  9. <body>
  10. <a href="page2.php">Page2</a>
  11. </body>
  12. </html>
  13.  
Expand|Select|Wrap|Line Numbers
  1. <?
  2. //page 2
  3. $newvariable = $HTTP_SESSION_VARS['variable'];
  4.  
  5. echo $newvariable;
  6. ?>
  7.  
Thanks,
Hussain
Nov 16 '07 #3
Atli
5,058 Expert 4TB
Ahh, I see.

The $HTTP_SESSION_VARS array is old and really should not be used.
Use the $_SESSION super-global instead.

I'm not really sure this will fix the problem, but it is a good place to start.

Also, I recommend using <?php ... ?> instead of <? ... ?>. The short-tags version can cause problems when moving between servers.

Consider this:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //first page
  3. session_start();
  4.  
  5. $_SESSION['variable'] = "Some value";
  6. ?>
  7.  
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //page 2
  3. $newvariable = $_SESSION['variable'];
  4.  
  5. echo $newvariable;
  6. ?>
  7.  
P.S.
Please post all your code inside [code] tags.

[code=php] PHP Code goes here [/code]

Thank you.
Nov 16 '07 #4
LacrosseB0ss
113 100+
I'm also having this problem. This post is mostly so I can subscribe and watch for answers here that may help me as well. Thanks!
Nov 17 '07 #5

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

Similar topics

1
by: gfuller | last post by:
- We have 2 aspx pages in a .NET project. The first sets a session variable and has a button that when clicked performs a 'redirect' to the second page which then reads the session variable. ...
9
by: Larry Woods | last post by:
I have a site that works fine for days, then suddenly, I start getting ASP 0115 errors with an indication that session variables IN SEPARATE SESSIONS have disappeared! First, for background...
14
by: Paul Yanzick | last post by:
Hello, I am trying to develop a book tracking application for my capstone in school, and am running into a problem. The application is an ASP.Net application written in C#. The first page you...
3
by: Rob | last post by:
I'm trying to use session variables to store datasets when moving from page to page (and returning). The datasets are small (I know some may comment on performance issues). It seems simple to use....
1
by: dsmith-nospam | last post by:
Hello, It would be great if someone knows the answer to this problem I'm getting bogged down with it. Basically I'm working with an ASP.NET solution that uses the Session object to maintain...
2
by: Stuart | last post by:
Hi there I am using several processes within an .asp application that store variables in to session - typically: Session("UniqueName") = Value I am having a hell of a time overwriting the...
5
by: Terry On Windigo | last post by:
I think I have figured out my problem but I don't know how to solve it. We are going to start using a forums package and do not want our users to have to login to both our site, and then again to...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
6
by: ChrisAtWokingham | last post by:
I have been struggling with unexpected error messages on an ASP.NET system, using SQL and C#. The application draws organisation charts, based on data stored in the SQL database. Some of the chart...
0
by: mfaisalwarraich | last post by:
Hi Everybody, I am submitting a form to the paypal and then returning to a url. return to the url is successful means the code is workin properly. but at the return url im having this 500 CGI...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.