473,626 Members | 3,936 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$_SESSION only seems to work part of the time for my site

11 New Member
I created a game called Mystic Crusade (www.mysticcrus ade.com) and it tends to work perfectly except for one thing, sometimes it doesn't register the session, i guess. For some reason, some of my users have to log in several times before they are logged in to stay. This is what I mean...

Most users log in and it takes them to their "home" page, then they can move around and do stuff in the game.

But some users log in, it takes them to their "home" page (which you have to be logged in to see) but when they try to move around the page, it's like as if they were not logged it. If you are not logged in, it kicks you off the game and you have to sign in again. These users will sign in again and again and it will eventually work. This problem has never affected me, but it does effect some users every time.

I use $_SESSION to register the user, the it takes them to their 'home' page via
[php] header('Locatio n: home.php');


exit;[/php]

and I do start the session on every page with session_start() ;

Please help me, I just don't understand why it seems to work only some of the time
Feb 26 '07 #1
14 1466
Motoma
3,237 Recognized Expert Specialist
This problem may have more to do with how you are destroying your sessions.
Tell me, what method are you using for keeping the session id?
Feb 26 '07 #2
snapple
11 New Member
This problem may have more to do with how you are destroying your sessions.
Tell me, what method are you using for keeping the session id?
I'm sorry, what do you mean? I assume that when you use $_SESSION it keeps the information until the browser is closed.

Here is an example on how I set them up
[php]
$name='collin';
$_SESSION['user'] = $name;
[/php]
Now, $name actually equals the username of the user, that was just an example.

to end the sessions I do this...
[php]
if (isset($_SESSIO N['user'])) {
unset($_SESSION['user']);
}
[/php]
which is located at logout.php
Feb 26 '07 #3
snapple
11 New Member
if someone tried to look at my website earlier, it was down because I was trying to figure it out, but I failed to do so. Someone please still help me.
Feb 27 '07 #4
snapple
11 New Member
if someone tried to look at my website earlier, it was down because I was trying to figure it out, but I failed to do so. Someone please still help me.
Come on, there has to be someone that can help me
Feb 28 '07 #5
Motoma
3,237 Recognized Expert Specialist
Come on, there has to be someone that can help me
I'm sorry, but you still haven't answered my question as to how you are handling Sessions. Are you using a Cookie to store the Session ID, or are you passing it around via POST or GET?

The way I usually log out is like so:
[php]
function logout()
{
$_SESSION = array();
session_regener ate_id(true);
session_destroy ();
}
[/php]

Methinks that your users may have a problem with their PHPSESSID Cookie getting removed, either by your system or by clearing the cache.
Feb 28 '07 #6
snapple
11 New Member
I've never really totally understood sessions, so I would have to guess that I use cookies. I defiantly don't do anything with post and get as far as sessions go.

I changed the way I delete sessions to how you showed me you did it. I currently don't know if that fixed anything (The problem doesn't occur with me).

Um... so I hope I answered your question on how I handle the sessions.

When I make the sessions I say something like

$_SESSION['username'] = $username;
Feb 28 '07 #7
Motoma
3,237 Recognized Expert Specialist
I would suggest, then, to read the article about Session Handling Functions. In particular, focus on the section about passing the session id.
Feb 28 '07 #8
snapple
11 New Member
Right, I knew all of that. I did some other research before I saw this post and found out that I pass the sessions by cookies. This really confuses me because it works after a few attempts at it. I'll see if changing the way the sessions are deleted does anything
Feb 28 '07 #9
snapple
11 New Member
So yeah, I talked to my friend who has the problem and it still occurs. He logged on to the site (took him two tries) then he logged out, closed the browser, reopened it, and it still took him two tries to log in.
Feb 28 '07 #10

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

Similar topics

0
1866
by: Taz | last post by:
comp.lang.php, I have recently launched the new Planet-Tolkien.com, one would think that writing a message board from scratch and a dynamic weather system, a simple session login would be the least of my problems right? Wrong. It would appear that for Mozilla and Opera keep a $_SESSION is not an issue and the $_SESSION is continued until the member logs out. However when members are using Internet Explorer browser (most
0
2477
by: Phil Powell | last post by:
What is the most standardized method of utilizing the CURL functions in PHP (version 4.3.2) to be able to retrieve the contents of a remote URL that happens to be dependent upon $_SESSION for its content display? I've tried the following class methods for display and I have most everything working until I get to a URL that requires $_SESSION: class Timer extends View {
4
1935
by: comp.lang.php | last post by:
This is an urgent request (as always) generate_admin_customer_position_dropdown($customerResult, $customerResult->id); print_r($_SESSION); This code will generate an HTML dropdown as well as set a $_SESSION
21
3052
by: axlq | last post by:
Someone please tell me if I've discovered a PHP bug. I'm sitting in front of several computers on my home network, behind a NAT firewall/router. I am testing my web site on these different computers (running different browsers, logged in as different users, etc.). My web site keeps track of users logged in through the use of $_SESSION. Here's the bizarre thing: All computers are logged off, then I log into my web site with one...
1
1326
by: bartdlr | last post by:
Hi, I got a problem to access the $_SESSION variable in my script. I wrote some login code: if the user logs in with his name and password a user object is stored in the $_SESSION variable. This all works fine , i can correctly read from that variable later on. I have an old version of my site under a domain name and the new site
5
3609
by: damezumari | last post by:
When a user logs in to my site http://iwantyourquestion.com I set $_SESSION to true if his username and password are OK. When he calls a page I check if $_SESSION is true. If it not I ask him to log in. Every page has at the start: session_start(); ob_start();
19
2181
nathj
by: nathj | last post by:
Hi, I am trying to get $_SESSION to work on my site. In order to learn this an dunderstand it better I have built two very simple test pages to see if i can access $_SESSION on both pages. Page 1 <?php /* Created on: 03/07/2007 */ session_start();?> <html> <body>
4
2341
by: dpinion | last post by:
Greetings, I am trying to do some simple session stuff. However it does not seem as though the session variable is being created for my site. I am running the latest version of PHP and apache that I installed as part of WAMP. Machine is XP SP2. Basically I am trying to do something simple such as: <?php
9
1810
nathj
by: nathj | last post by:
Hi, I am having a spot of bother with the use of $_SESSION. They are gernally working absolutely fine with one exception. On my form I have a capthca security image, when this image is built is stores the value in a $_SESSION variable. When the user types the security code into the box the onchange event calls my javascript function. This in turn calls a PHP page. It's an AJAX thing which is also generally working fine. The trouble is...
0
8266
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8199
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7196
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5574
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2626
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 we have to send another system
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.