23, November 2008

PHPSESSID and Internet Explorer - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ 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

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


It's time to use PHP5!


« on: Jun 03, 2006, 05: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?



Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8250
42487 credits
Members referred : 3



« Reply #1 on: Jun 03, 2006, 06: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 Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Jun 06, 2006, 04: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?


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8250
42487 credits
Members referred : 3



« Reply #3 on: Jun 06, 2006, 04: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 Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Jun 06, 2006, 05: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.


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8250
42487 credits
Members referred : 3



« Reply #5 on: Jun 06, 2006, 05: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 Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Jun 06, 2006, 05: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.


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8250
42487 credits
Members referred : 3



« Reply #7 on: Jun 06, 2006, 05: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 Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Jun 06, 2006, 05: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?


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8250
42487 credits
Members referred : 3



« Reply #9 on: Jun 06, 2006, 05: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 Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #10 on: Jun 06, 2006, 05: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?


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8250
42487 credits
Members referred : 3



« Reply #11 on: Jun 06, 2006, 05:36:23 PM »

If it is stored in a cookie, you can.

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

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #12 on: Jun 06, 2006, 05: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)


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8250
42487 credits
Members referred : 3



« Reply #13 on: Jun 06, 2006, 05: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 Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #14 on: Jun 06, 2006, 05: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?


Last blog : Just a better Internet portal provided by Google
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #15 on: Jun 06, 2006, 05: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)


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8250
42487 credits
Members referred : 3



« Reply #16 on: Jun 06, 2006, 05: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 Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #17 on: Jun 06, 2006, 05: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?


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8250
42487 credits
Members referred : 3



« Reply #18 on: Jun 06, 2006, 05: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 Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #19 on: Jun 06, 2006, 06: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);
}
?>


Last blog : Just a better Internet portal provided by Google
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....

Topic sponsors:
Get a permanent link here for $1.99!


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?
Nov 23, 2008, 01:12:31 PM





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!


Forum Statistics
Total Posts: 37.756
Total Topics: 7.652
Total Members: 4.400
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: GregH

26 Guests, 5 Users online :

11 users online today:



Readers

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