473,487 Members | 2,483 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

session variables lost unexpectedly

xxoulmate
77 New Member
why there's an instance.
my page been session timeout.

code something like this:
Expand|Select|Wrap|Line Numbers
  1. //login page
  2. session_start();
  3. $_SESSION['var1'] = "username";
  4. //will be redirected to main.php when logged in
  5. header('location:main.php');
  6.  
Expand|Select|Wrap|Line Numbers
  1. //main.php
  2. session_start();
  3. echo session_id();
  4. foreach($_SESSION as $key=>$value)
  5. {
  6. echo $key." = ".$value."<br>";
  7. }
  8.  
when i refresh the page of main.php
sometime i get no session.
something like all my session variables been gone.
but the sessionid still the same.
my script didnt unset or use session_destroy()
therefore it must be there.
Jul 23 '10 #1
4 2148
dlite922
1,584 Recognized Expert Top Contributor
You might be sending the header due to content in your PHP file before session start.

Make sure the first character in your PHP file is <?php. No spaces or anything else. Those should be on the first line, first character of the file. And make sure you immediately call session_start() without echoing or doing anything else.

Let me know if that worked or not.
Jul 23 '10 #2
xxoulmate
77 New Member
session start is at the begginning of the script.
and there is no space either on the first line.

is it something to do with what they call garbage collector.
Jul 26 '10 #3
Dormilich
8,658 Recognized Expert Moderator Expert
and there is no space either on the first line.
you may not always see the characters, ref. http://bytes.com/topic/php/insights/...s-already-sent

on the other hand side, if there were indeed whitespace, it would have triggered a warning.

is it something to do with what they call garbage collector.
that would depend on your session settings in php.ini
Jul 26 '10 #4
xxoulmate
77 New Member
yep it was., it will trigger warning of character already established.,

my system has a an option of session length: forever
but theres' a time (no definite time). all session variables gone. so my system logout the user. That's really the problem.
Aug 3 '10 #5

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

Similar topics

1
2707
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. ...
2
4262
by: Alex | last post by:
Thank you in advance. My ASP page 1 redirect user to third party's website, after the process at third party is finished, in 3rd party's page, there is one link to route user back to my...
1
1607
by: gupta | last post by:
I am having a strange problem with my Web App. When I launch my web App using localhost or an ip address (e.g 192.133.98.32) all the sesssion variables works fine and Session_start event in...
2
1984
by: Newbie | last post by:
Hi All, I would really appreciate any ideas / clues on this issue which I am facing. I have a asp.net application, the problem is with maintaining session variables while using authentication for...
7
2945
by: Erik | last post by:
I have an application that uses sessions variables a lot but one I publish the application on the prod server these variables are lost. The application is written i c# 2.0 and I've set the...
1
996
by: RonL | last post by:
I was reading that Session State is lost when the application domain is re-created (e.g. when the web app code is updated or the config is changed). Does this mean that data that is stored in...
0
1215
by: MirkoGeest | last post by:
(Webmaster: sorry, I posted this first at the General Software Engineering category, but I think this goes here) I'm using Visual Basic with Web Forms on .NET 2003 and I'm experiencing a very...
5
1470
by: albertcliang | last post by:
I've got an odd case where I'm developing on a Win2k box and everything works fine (no, that's not the odd part). However, when I publish my code to a test box (2k3 Server, single processor), I...
2
4226
by: maxkumar | last post by:
Hi, I am running a ASP.NET 1.1 site on Win Server 2003 with IIS 6.0. The website has been running for about 1.5 years now. In the past, we used to have random cases of session variables getting...
8
3016
by: Eddie | last post by:
I am having difficulty in setting variables in a session, and then accessing those variables throughout the web pages that they click on. After having them set a user name and password,...
0
7108
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.