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

Frustrating PHP Session Error

Hi all,

I just signed up on your site because I saw a discussion about Sessions and figured some of you guys might know something. I've just started making the site www.complocated.com and you can register login / logout and edit your profile etc. I have one major and really annoying error, in which my session_id is refreshing.

Basically when you login, it searches the database for a field with your username and password (md5ed or course) and if it finds you it edits your 'last online' field to the currently running session id of the page. This means that whilst the session is running you should always be logged in because the session you're currently on is that same as the one in the sql database.

The problem is that when the user logs in for the first time, and in some other random stages in the site with other people, it is logging them out. I debugged by echoing the session ID and found out that it was changing. My site runs of 1 main index page with the string session_start and so I can't understand why the session would change at any point.

I'm also kind of looking for a partner for work on the site, who could potentially earn quite a bit of money from the adverts of the site once it goes live. If you want to see the ideas for the site, please go here http://evenicoulddoit.com/community/viewtopic.php?t=743 which is my other sites community forum. Many thanks and if any of you can fix this error you'll get some eLoving lol.

Seriously though if anyone knows my error I would be so so so grateful.

Ian
Jun 30 '07 #1
7 1549
mwasif
802 Expert 512MB
Did you notice at what point session id change?
Keep one thing in mind, session id created on www.site.com and site.com both are different. Make sure you dont have such case.
Jun 30 '07 #2
Mate - I love you <3

OK 1 thing, they login and I was either using meta redirect or header to redirect them. But how could I do that on either www. or http://

Use Preg match in the page url to find http and if it's not present then redirect to a different page?

Many thanks <3
Jun 30 '07 #3
mwasif
802 Expert 512MB
There is a simple soultion if you are having problem due to www.site.com and site.com. Set php.ini variable "session.cookie_domain" value to your domain before initializing session. like

[PHP]ini_set ("session.cookie_domain", ".yourdomain.com");
session_start();[/PHP]

Note the dot before domain name:) This will set session cookie for both yourdomain.com and www.yourdomain.com.
Jun 30 '07 #4
I'm not running it on cookies but just a session script at the moment. How would I go about doing this?
Jun 30 '07 #5
mwasif
802 Expert 512MB
Use this line before session_start() and try
[PHP]ini_set ("session.cookie_domain", ".yourdomain.com");[/PHP]

Replace yourdomain.com with your domain.
Jun 30 '07 #6
Mate I love you <3

Do you like my site?
Jun 30 '07 #7
mwasif
802 Expert 512MB
Nice site. You have to work hard for SEO:)
Jun 30 '07 #8

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

Similar topics

3
by: sjanie | last post by:
The error code is: Microsoft JScript compilation error '800a03ec' Expected ';' /bicc.nl/Connections/BICCwebsite.asp, line 2 Set Conn = Server.CreateObject("ADODB.Connection") ----^
7
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
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 -...
1
by: Simon Harvey | last post by:
Hi, I'm hoping someone can help me witht he following problem: I have a fairly simple page that has a sort form and a button for adding the forms details to an arraylist. When the button is...
7
by: Spencer H. Prue | last post by:
Hello!, I have a using system.web.sessionstate directive one the top of each of two web pages. On the first page I have the dataadapter, dataconnection, and dataset (also in the component tray)....
3
by: Loui Mercieca | last post by:
Hi, I have a very strange and frustrating error. I developed an application, tested it and it works fine. Then i deploy it to another machine ( no installation, direct file transfer ) but it...
11
by: Jerry | last post by:
I'm using this code: Dim strName For Each strName in Session.Contents Response.Write strName & " - " & Session.Contents(strName) & "<BR>" Next If I only do a response.write strName, it shows...
5
by: lyealain | last post by:
<% If Session("username") = "" Then Response.Redirect("/CLS/Login.asp") End If Dim conn Dim connectstr Dim db_name, db_username, db_userpassword Dim db_server Dim res
3
by: Sejoro | last post by:
At this point in life, I thought syntax wouldn't be a problem, but it is. I'm trying to write yet another school program, but keep getting compile errors in the main function when I try to pass an...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.