473,320 Members | 2,092 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.

problem with session variables

Elsewhere on a form page I am declaring a variable

*******************************
session_start();
$_SESSION['testvar'] = "sometext";

At the top of the page that will process the form code I have this line.

session_start();
$testppp=$_SESSION['testvar'];

echo $testppp;

*******************************

But nothing is echoed. What am I missing?
Garry Jones
Sweden
Oct 9 '06 #1
9 1018
If you use PHP on Windows you have to define session.save_path in case
you use sessions stored as files. Check this:
http://ro2.php.net/manual/en/functio...-save-path.php

Let me know it this was the problem.

Garry Jones wrote:
Elsewhere on a form page I am declaring a variable

*******************************
session_start();
$_SESSION['testvar'] = "sometext";

At the top of the page that will process the form code I have this line.

session_start();
$testppp=$_SESSION['testvar'];

echo $testppp;

*******************************

But nothing is echoed. What am I missing?
Garry Jones
Sweden
Oct 9 '06 #2
iulian.ilea" <iu*********@gmail.comskrev i meddelandet
news:11**********************@i3g2000cwc.googlegro ups.com...
If you use PHP on Windows you have to define session.save_path in case
you use sessions stored as files. Check this:
http://ro2.php.net/manual/en/functio...-save-path.php

Let me know it this was the problem.
No, thats not the problem!

:(

Garry
Oct 9 '06 #3
Garry Jones wrote:
Elsewhere on a form page I am declaring a variable

*******************************
session_start();
$_SESSION['testvar'] = "sometext";

At the top of the page that will process the form code I have this line.

session_start();
$testppp=$_SESSION['testvar'];

echo $testppp;

*******************************

But nothing is echoed. What am I missing?
Garry Jones
Sweden

Are you calling session_start() before ANY output is sent to the
browser? This includes html, php output or even white space.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 9 '06 #4
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:tb******************************@comcast.com. ..
Are you calling session_start() before ANY output is sent to the browser?
This includes html, php output or even white space.
No. Are you supposed to?

I can session_start in similar code on other sites and they work ok.

My php session start is in a segment of code called in by a ´condition"
being met)

This problem is persisting. I need to carry a variable forward past a form
being read in and processed,

Garry Jones
Sweden
Oct 9 '06 #5
"Garry Jones" <ga*********@morack.seskrev i meddelandet
news:eg**********@yggdrasil.glocalnet.net...
This problem is persisting.
More code

form code
session_start();
$_SESSION['testvar'] = "sometext";
echo $_SESSION['testvar'];

At the top of the page that will process the form code I have this line.
session_start();
echo $_SESSION['testvar'];

The first "echo $_SESSION['testvar']" works
The second one does not so the session varible is reset to null. But WHY?

Garry Jones
Sweden
Oct 9 '06 #6
Garry Jones wrote:
"Garry Jones" <ga*********@morack.seskrev i meddelandet
news:eg**********@yggdrasil.glocalnet.net...
> This problem is persisting.
[...]
At the top of the page that will process the form code I have this line.
session_start();
echo $_SESSION['testvar'];
Try this in the page that will process the form code

if (!headers_sent()) {
session_start();
echo $_SESSION['testvar']
} else {
echo 'Cannot start session. Headers have already been sent.';
}

Then, if it complains with "Cannot start session. ..." move the lines up
in the source code until it stops complaining.
Links:
http://www.php.net/headers_sent
http://www.php.net/session

--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot
Oct 10 '06 #7
Garry Jones wrote:
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:tb******************************@comcast.com. ..

>>Are you calling session_start() before ANY output is sent to the browser?
This includes html, php output or even white space.


No. Are you supposed to?

I can session_start in similar code on other sites and they work ok.

My php session start is in a segment of code called in by a ´condition"
being met)

This problem is persisting. I need to carry a variable forward past a form
being read in and processed,

Garry Jones
Sweden

Yes. Try adding this code just before you call session_start() and
you'll see your error:

ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_NOTICE);

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 10 '06 #8
Hmm Garry Jones <ga*********@morack.sewrote:
But nothing is echoed. What am I missing?
sessions_start() must be the first command before you use any output
function

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

2be || !2be $this =mysql_query();
Oct 10 '06 #9
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:Pc******************************@comcast.com. ..
Yes. Try adding this code just before you call session_start() and
you'll see your error:
The problem was that my web hotel had this function disabled. I was able to
go in and change the setting and now it works.

Thanks for all your replies.

Garry Jones
Sweden

Oct 10 '06 #10

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

Similar topics

18
by: ZoombyWoof | last post by:
Hi. Im very new to php, and I have a problem here that I cant find the solution for. I have problems with session variables, I want some variables to maintain their value between different php...
13
by: Mimi | last post by:
Hello, I am having trouble using the session vars in PHP 4.3.9 OS: Win XP Prof Web Server IIS (is local and there are no links to other servers from the web pages I work on) Browser: IE 6.0 ...
1
by: Jonathan Chong | last post by:
I have problem with AOL browser (IE and Netscape are OK) accessing my Web site after putting up a load balancer that will go to W1 or W2. The problem does not happen when there is only Web server...
3
by: Gary | last post by:
I am having a strange problem that I cannot solve. I have an asp page that I use for a user to login and gain access to other pages. When the user logs in I set a couple of session variables like...
7
by: Adam Short | last post by:
I'm having all sorts of problems with Sessions, I've been using them for years with out a hitch, all of a sudden the last 6 - 12 months since getting our new Win2003 server it's all gone shakey!!!...
5
by: Newton | last post by:
Hi, I got here the following problem. I am programming web application for examing students. After student will log on I need to keep his ID, Privileges, Login, Password for manipulating with...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
8
by: Ashish | last post by:
Incase the problem got bogged down reposting... Hi Gregory, I think I didnt make myself much clear. The problem is: 1. I have one ASP.NET application (no classic asp) and it has a main page...
0
by: Alexander Widera | last post by:
hello all, i have a problem ... like I already discussed in the thread "session empty" I have the following problem: I created a completely new web... i added 2 files: sessiontest1.aspx:
3
by: stclaus | last post by:
Hi, I'm currently experiencing a problem using sessions under php 4.4.2. I store variables and objects inside session variables, and all works well under php 5.x, but when I upload those pages to...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: 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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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.