28, May 2012

PHPSESSID and Internet Explorer - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: PHPSESSID and Internet Explorer
« previous next »
Pages: [1] 2 Print
Instabuck - The easy way to sell digital products online

Author Topic: PHPSESSID and Internet Explorer  (Read 7020 times)
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« on: Jun 03, 2006, 04:20:40 pm »

Hello,

Some of you know the problem about the phpsessid in IE:

Every windows gets his own ID that will say there are several sessions at the same time (very bad)
what is the best way to solve this?

set a cookie like:
Code:
<?php
if(!$_COOKIE['PHPSESSID']) setcookie("PHPSESSID",  session_id());

or using this directive:
session.use_only_cookies

or something different?


I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Jun 03, 2006, 05:20:25 pm »

I had the same problem too, but I haven't looked at it yet.

I will post you when I check this out.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Jun 06, 2006, 03:52:09 pm »

There are only new session id's for new windows if they are opend f.e. via the shortcut on your desktop. If you navigate through a link (tartget=blank) then the same ID is used. Is this a problem for IE users?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #3 on: Jun 06, 2006, 03:58:33 pm »

I am not sure this is happening.

At least I have used sites with new window links that kept the session.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Jun 06, 2006, 04:05:50 pm »

I am not sure this is happening.

At least I have used sites with new window links that kept the session.
This is what I say a link opened in  a new window is OK but if you open a new window bij clicking the blue E and entering the same website via the address bar it goed wrong.

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #5 on: Jun 06, 2006, 04:11:52 pm »

Oh, I see.

The only thing you can do about that is managing sessions with cookies (I mean with real cookies, as sessions as using cookies anyway)

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Jun 06, 2006, 04:14:47 pm »

this is the problem I think:

If the server time is not properly set, e.g(it is behind the client time).    Excution of the following code

session_set_cookie_params(2000);
session_start();

will NOT set/send cookie to  Internet Explorer 6.0,

even though it will set the cookie on Mozilla/Firebird browser.  But the cookie will get set without the session_set_cookie_params();

Same holds true for following code,

$expiry = 60*30;
session_start();
setcookie(session_name(),session_id(), time()+$expiry, "/");
 

For some reason IE is really sensitive to cookie times. It won't even accept the cookie!!
 This took me quite a while to figureout, for I thoguht it was an IE cookie security issue.

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #7 on: Jun 06, 2006, 04:19:23 pm »

Regarding sessions, it keeps cookies only for the current browser session.

To make it keep the cookie you have to use the cookie functions without using session ( session_start )


Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Jun 06, 2006, 04:21:03 pm »

Regarding sessions, it keeps cookies only for the current browser session.

To make it keep the cookie you have to use the cookie functions without using session ( session_start )



this is the magic: session_set_cookie_params(2000);

but how many seconds?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #9 on: Jun 06, 2006, 04:29:58 pm »

I guess 2000 seconds is fine, but it also depends on the security level you want for the specific site.


For a forum you can set it to 30 minutes, but for a web application 15 minutes is a lot.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #10 on: Jun 06, 2006, 04:32:51 pm »

I guess 2000 seconds is fine, but it also depends on the security level you want for the specific site.


For a forum you can set it to 30 minutes, but for a web application 15 minutes is a lot.
yes right, but if you have re-opend a window within this 15 minutes you can continue the old session?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #11 on: Jun 06, 2006, 04:36:23 pm »

If it is stored in a cookie, you can.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #12 on: Jun 06, 2006, 04:37:56 pm »

If it is stored in a cookie, you can.
you have always a cookie, if session_start() is used (at last in FF)

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #13 on: Jun 06, 2006, 04:41:40 pm »

That's true, but IE will keep this cookie only in the open browser (in other words the session cookie does not work as a reqular cookie in IE)

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #14 on: Jun 06, 2006, 04:45:21 pm »

... what if the phpsessid cookie is expired and you are logged in on some page, do you have to log in again?

Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #15 on: Jun 06, 2006, 04:46:20 pm »

That's true, but IE will keep this cookie only in the open browser (in other words the session cookie does not work as a reqular cookie in IE)
yes that's looks to be the difference, that why it's only available in the "first" main window (and his childs)

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #16 on: Jun 06, 2006, 04:48:45 pm »

... what if the phpsessid cookie is expired and you are logged in on some page, do you have to log in again?

You can set the expiriation time of the cookie on every page load. This way it will work like a normal session.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #17 on: Jun 06, 2006, 04:54:32 pm »


You can set the expiriation time of the cookie on every page load. This way it will work like a normal session.
you say I have to use f.e. the this value "gc_maxlifetime" in every page? this way each session and phpsessid has the same experation time? and if someone has logged out I have to set a negative value to the cookie?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #18 on: Jun 06, 2006, 04:59:20 pm »

No. The gc_lifetime is a general attribute. Not for the specific cookie.

I think what you need here is to set_cookie again in every pageview.

If the user log out you can destroy the cookie(eg. setcookie ('XXX', "", time() - 3600) ).

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #19 on: Jun 06, 2006, 05:10:44 pm »

yes but the genarel value should be the same (by default) then my cookie value...

with this kind of code:
Code:
<?php
$expire 
ini_get("session.gc_maxlifetime");
if (empty(
$_COOKIE['PHPSESSID'])) {
session_set_cookie_params($expire);
session_start();
} else {
session_start();
setcookie("PHPSESSID"session_id(), time() + $expire);
}
?>

Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=2717
Tags : forums internet explorer cookies browsers snippets Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] 2 Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: PHPSESSID and Internet Explorer
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 10:36:36 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.