Hi everybody,
I am moving a php site to new hosting, and what was working fine on the old hosting is now broken on new hosting. The problem is that session_start is always creating a new session, even though one exists. I can see that the cookie is created just fine locally on login, and the matching session file is created on the server. But once I go to a new page, my checklogin() calls session_start which returns a new empty session, and I am automatically logged out.
Here is how I create the session during login:
[PHP]if ($rs->RecordCount( ) == 1) { // Found a partner
session_start() ;
$_SESSION['real-usr'] = $usr;
}[/PHP]
Here is how I check that the user is logged in:
[PHP]function checkLogin() {
session_start() ;
if (empty($_SESSIO N['real-usr'])) {
echo "Session expired. Please login";
include("login. php");
die();
}
}[/PHP]
Note that it isn't shared hosting, so there shouldn't be a problem with other processes deleting the temporary session files. (Plus I can see that the temp files are still there.)
I am using PHP 5.2.2. Here is an exerpt from phpinfo()
session
Session Support enabled
Registered save handlers files user
Registered serializer handlers php php_binary wddx
Directive Local Value Master Value
session.auto_st art Off Off
session.bug_com pat_42 On On
session.bug_com pat_warn On On
session.cache_e xpire 180 180
session.cache_l imiter nocache nocache
session.cookie_ domain .semoptimizer.c om .semoptimizer.c om
session.cookie_ httponly Off Off
session.cookie_ lifetime 0 0
session.cookie_ path \ \
session.cookie_ secure Off Off
session.entropy _file no value no value
session.entropy _length 0 0
session.gc_divi sor 1000 1000
session.gc_maxl ifetime 1440 1440
session.gc_prob ability 1 1
session.hash_bi ts_per_characte r 5 5
session.hash_fu nction 0 0
session.name PHPSESSID PHPSESSID
session.referer _check no value no value
session.save_ha ndler files files
session.save_pa th C:\Temp C:\Temp
session.seriali ze_handler php php
session.use_coo kies On On
session.use_onl y_cookies Off Off
session.use_tra ns_sid 0 0
If anybody can give me a hand, it would be much appreciated. I have been doing google searches all day and investigating different options, but haven't figured anything out.
Thanks,
jessica
6 4004 epots9 1,351
Recognized Expert Top Contributor
i'm not 100% sure but maybe the problem is that your calling session_start() inside your functions.
session_start() should be the first line (after the <? tag), before any other code is used, and should only be called once per php file.
does that work?
i'm not 100% sure but maybe the problem is that your calling session_start() inside your functions.
session_start() should be the first line (after the <? tag), before any other code is used, and should only be called once per php file.
does that work?
Nope, that didn't fix it. It's still doing the same thing.
Motoma 3,237
Recognized Expert Specialist
This may be an issue with the session cookie options. Try creating a cookie yourself and see if you get the same Host, Path, and Domain information in that cookie as you do in your Session cookie.
This may be an issue with the session cookie options. Try creating a cookie yourself and see if you get the same Host, Path, and Domain information in that cookie as you do in your Session cookie.
Thanks! That did the trick. The domain was missing a www and the path was / instead of \.
Motoma 3,237
Recognized Expert Specialist
Thanks! That did the trick. The domain was missing a www and the path was / instead of \.
Glad you got everything working, and thanks for posting the solution so others may learn too.
Come back to the site any time you have a problem.
jx2 228
New Member
try that :
[PHP]if(!(session_id ()))session_sta rt();[/PHP]
why do you use it many times?
i woud use it once at first line
let me know if it works...
jx2
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Wynter |
last post by:
I've been smacking into one brick wall after the next in converting some of my code from ASP Classic to ASP.NET. This one is a real bugger. I use Session Variables to help with User Security. If they drop a key Session Variable then they are signed out of the application.
I create this session variable at Signon in Classic ASP code, but as I am finding out the hard way later ASPX code modules are not picking up these session variables. Is...
|
by: soudifathy |
last post by:
whene i use localhost/... and navigate through web site the session id
not changed
but whene i use computername/.. (ie. computerName/home.aspx) sessionID
is created each page and the data is lost
what is the problem?
thanks.
|
by: Andrew J. Marshall |
last post by:
I want to create a class that must receive a parameter when instantiated.
In other words, I do not want it to have a "Public Sub New()".
1) Does VB.NET create a default public constructor if I do not declare one?
2) I've read that I can have a "Private Sub New()" which should take care of
my needs. Comments?
Thanks,
Andrew
|
by: Jonathan Wood |
last post by:
Greetings,
I was wondering if anyone here has a good understaning of the Session
object. I know there are options like the Session.Abandon method and the
regenerateExpiredSessionId setting, although I do not understand what they
do.
Can anyone tell me if it's possible for a recycled session to still contain
the old data? I had a couple of reports that where users said they logged on
and saw another user's data. On this site, there...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |