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

session id changes in Textpattern based on URL

This was driving me crazy, but I've finally figured out what is
happening, but I'm not sure why. I had to implement some extra
security for a web site that has added a blog (Textpattern). Sorry I
can't give the address out because the site is a prototype and I've
signed a non-disclosure agreement. I would type in the URL
example.com, I would enter my user name and password, and browse the
site. When I clicked on the blog link it took me to the main blog
page, but clicking any of the other links to blog articles wouldn't
work. After using the LiveHTTPHeaders plugin for Firefox, I saw that
the PHPSESSID was changing every time I accessed the blog. However it
worked on other computers no problem. Come to find out if I entered
the URL with www.example.com (notice the www) everything worked
perfectly and the sessions never reset. I think Textpattern is calling
a page called css.php using the entire URL www.example.com which is
causing the session reset if I started browsing the site using the URL
example.com.

Is this typical for sessions? To check the session, I'm doing the
following:

session_start();

if (!isset($_SESSION['valid_user'])) {
die('Restricted access');
}

The books say this is the way to do it, but is it the best/right way
to do it?

Thanks!

May 15 '07 #1
7 1597
wh*******@gmail.com wrote:
This was driving me crazy, but I've finally figured out what is
happening, but I'm not sure why. I had to implement some extra
security for a web site that has added a blog (Textpattern). Sorry I
can't give the address out because the site is a prototype and I've
signed a non-disclosure agreement. I would type in the URL
example.com, I would enter my user name and password, and browse the
site. When I clicked on the blog link it took me to the main blog
page, but clicking any of the other links to blog articles wouldn't
work. After using the LiveHTTPHeaders plugin for Firefox, I saw that
the PHPSESSID was changing every time I accessed the blog. However it
worked on other computers no problem. Come to find out if I entered
the URL with www.example.com (notice the www) everything worked
perfectly and the sessions never reset. I think Textpattern is calling
a page called css.php using the entire URL www.example.com which is
causing the session reset if I started browsing the site using the URL
example.com.

Is this typical for sessions? To check the session, I'm doing the
following:

session_start();

if (!isset($_SESSION['valid_user'])) {
die('Restricted access');
}

The books say this is the way to do it, but is it the best/right way
to do it?

Thanks!
I don't know about Textpattern - you should ask their support people.
But www.example.com is different than example.com, and the browser won't
send a cookie from one to the other.

But when you say "calls a pages called css.php" - what do you mean? Is
this a redirect? An include? A link?

As for testing - yes, this is one way. I don't use die(), but the
concept is the same.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 15 '07 #2
In article <3f******************************@comcast.com>,
js*******@attglobal.net says...
wh*******@gmail.com wrote:
This was driving me crazy, but I've finally figured out what is
happening, but I'm not sure why. I had to implement some extra
security for a web site that has added a blog (Textpattern). Sorry I
can't give the address out because the site is a prototype and I've
signed a non-disclosure agreement. I would type in the URL
example.com, I would enter my user name and password, and browse the
site. When I clicked on the blog link it took me to the main blog
page, but clicking any of the other links to blog articles wouldn't
work. After using the LiveHTTPHeaders plugin for Firefox, I saw that
the PHPSESSID was changing every time I accessed the blog. However it
worked on other computers no problem. Come to find out if I entered
the URL with www.example.com (notice the www) everything worked
perfectly and the sessions never reset. I think Textpattern is calling
a page called css.php using the entire URL www.example.com which is
causing the session reset if I started browsing the site using the URL
example.com.

Is
This is somewhat disturbing.

Given that this happens - how do you prevent it causing a problem - IE
how can you force this discrepancy to correct itself so the user session
always remains safe?
May 15 '07 #3
harvey wrote:
In article <3f******************************@comcast.com>,
js*******@attglobal.net says...
>wh*******@gmail.com wrote:
>>This was driving me crazy, but I've finally figured out what is
happening, but I'm not sure why. I had to implement some extra
security for a web site that has added a blog (Textpattern). Sorry I
can't give the address out because the site is a prototype and I've
signed a non-disclosure agreement. I would type in the URL
example.com, I would enter my user name and password, and browse the
site. When I clicked on the blog link it took me to the main blog
page, but clicking any of the other links to blog articles wouldn't
work. After using the LiveHTTPHeaders plugin for Firefox, I saw that
the PHPSESSID was changing every time I accessed the blog. However it
worked on other computers no problem. Come to find out if I entered
the URL with www.example.com (notice the www) everything worked
perfectly and the sessions never reset. I think Textpattern is calling
a page called css.php using the entire URL www.example.com which is
causing the session reset if I started browsing the site using the URL
example.com.

Is

This is somewhat disturbing.

Given that this happens - how do you prevent it causing a problem - IE
how can you force this discrepancy to correct itself so the user session
always remains safe?
Harvey,

I've never had to do it myself, but I understand you can change the
domain name for session cookies in your php.ini file, i.e.

session.cookie_domain = .example.com

To have the cookie available for all domains you must have the leading
period.

As I said - I haven't tried it, because I haven't had the problem. But
it might be your fix.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 15 '07 #4
I don't know about Textpattern - you should ask their support people.
Butwww.example.comis different than example.com, and the browser won't
send a cookie from one to the other.

But when you say "calls a pages called css.php" - what do you mean? Is
this a redirect? An include? A link?

As for testing - yes, this is one way. I don't use die(), but the
concept is the same.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
I asked the same question in the Textpattern forum, but the response
was basically RTFM with a link to the PHP sessions section on php.net.
I read the session section, but I still don't see what I did wrong in
terms of using session_start().

The css.php is an include. From what I understand it creates the link
to the CSS file based on the Textpattern configuration file.

Thanks for the response!

May 15 '07 #5
On May 15, 10:14 am, harvey <harvey....@blueyonzders.comwrote:
In article <3fednelwTe4PENTbnZ2dnUVZ_rCsn...@comcast.com>,
jstuck...@attglobal.net says...
This is somewhat disturbing.

Given that this happens - how do you prevent it causing a problem - IE
how can you force this discrepancy to correct itself so the user session
always remains safe?
On May 15, 10:14 am, harvey <harvey....@blueyonzders.comwrote:
In article <3fednelwTe4PENTbnZ2dnUVZ_rCsn...@comcast.com>,
jstuck...@attglobal.net says...

This is somewhat disturbing.

Given that this happens - how do you prevent it causing a problem - IE
how can you force this discrepancy to correct itself so the user session
always remains safe?
One person on the Textpattern forum did recommend doing this (I'm
assuming this goes in the .htaccess file or httpd.conf file):

<IfModule mod_rewrite.c>
RewriteEngine on

# no www ------------------
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
</IfModule mod_rewrite.c>
The above automatically redirects people to the non-www version of any
given url.

I'd also like to see if Jerry's suggestion works.

Thanks again for the help.

May 15 '07 #6

Does this problem affect everyone using Paypal & other services ?

I've now managed to replicate this on my test site and believe it may
well affect me but I have yet to find a solution. Nothing suggested so
far can solve this.

I use an ISP and have user access and execution rights but can't modify
either PHP.INI or apache startup files. (shared access means I'm not
allowed to re-start - obviously)

I have a site that communicates with paypal that sells data files
but I can't guarantee people will type in the WWW when they enter the
site (at whatever page) so they could start their session either with or
without it.

So I have a dilema - the required return address from paypal can either
include or exclude the WWW portion. It can't do both.

This means if there is a missmatch the sales transaction will fail.
Even worse - there is no way to identify that this was the cause
creating random transaction failures potentially (statistically over
time) of 50%

This is going to cost me money and I suspect everyone else using
any service such as this will suffer too.

This obviously isn't a minor problem.

If anyone can help - an idiots guide would be welcome ;-)

May 22 '07 #7
harvey wrote:
Does this problem affect everyone using Paypal & other services ?

I've now managed to replicate this on my test site and believe it may
well affect me but I have yet to find a solution. Nothing suggested so
far can solve this.

I use an ISP and have user access and execution rights but can't modify
either PHP.INI or apache startup files. (shared access means I'm not
allowed to re-start - obviously)

I have a site that communicates with paypal that sells data files
but I can't guarantee people will type in the WWW when they enter the
site (at whatever page) so they could start their session either with or
without it.

So I have a dilema - the required return address from paypal can either
include or exclude the WWW portion. It can't do both.

This means if there is a missmatch the sales transaction will fail.
Even worse - there is no way to identify that this was the cause
creating random transaction failures potentially (statistically over
time) of 50%

This is going to cost me money and I suspect everyone else using
any service such as this will suffer too.

This obviously isn't a minor problem.

If anyone can help - an idiots guide would be welcome ;-)
This isn't a problem just with Paypal - it's how cookies work in all
browsers.

You don't necessarily need to set it in your php.ini file. You should
also be able to do it in your .htaccess file (if your hosting company
allows it), i.e.

php_value session.cookie_domain .example.com

Or, you can set up your .htaccess file to automatically reroute request
from example.com to www.example.com.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 22 '07 #8

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

Similar topics

4
by: David B | last post by:
Hi, Could somebody please tell me how I check whether a session is dead based soley on the Session.SessionID. At present the timeout is set to 20 minutes in IIS, I am aware that I can reset...
4
by: Nedu N | last post by:
how to make session not to time out (infinite life time)? if not possible how to increase the time out? for my application its timing out fairly very quick even though i have time out = 99999
2
by: Boban Dragojlovic | last post by:
I'm building a complex web-based reservations system. Gathering the user's data requires between 8 and 15 pages (depending on which options they are interested in). I use the "Session" object to...
31
by: Harry Simpson | last post by:
I've come from the old ASP camp where session variables were not used. When i started using ASP.NET in 2001, I started using them again because it was ok from what I'd read. I've been merrily...
4
by: | last post by:
I'm not sure what to think of this. In the appliacation, upon postback, users screens will get mixed up. Meaning... Perhaps on my screen im working with a particular set of data. I click a button...
7
by: Ty | last post by:
Hi, All- I have a custom httphandler that outputs an image to the browser based upon some user input. I'd like to be able to store information about that image in session and have them...
1
by: jesibl | last post by:
Hi All, I have an ASP .NET 2.0 web based app which should change content based on a variable passed in the query string. Let's say the variable is called ID and the variations are A, B and C. ...
4
by: three-eight-hotel | last post by:
I'm somewhat of a newbie to PHP coding, but have developed a site using the technology, and have been pleasantly surprised by the capabilities offered. I am more comfortable in the ASP world,...
0
by: lawrence k | last post by:
I've never worked with Textpattern before. I've been asked to transfer it to a new server. I moved the files and the database but I'm still getting an error message: ...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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...

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.