By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,676 Members | 1,325 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,676 IT Pros & Developers. It's quick & easy.

if cookie is disabled then session will work or not???????????

P: n/a
hi

i am using session in php. but if the client has disabled his cookie
then will my session work or not?????????

thxs for your reply in advance.............

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
vishal (vi************@yahoo.co.in) wrote:
: hi

: i am using session in php. but if the client has disabled his cookie
: then will my session work or not?????????

: thxs for your reply in advance.............

Please try it yourself and see. In general both possible answers can be
true depending on the server.
--

This space not for rent.
Jul 17 '05 #2

P: n/a
>vishal (vi************@yahoo.co.in) wrote:
: hi

: i am using session in php. but if the client has disabled his cookie
: then will my session work or not?????????


Try picking the bones out of the following. This seems to work OK as
far as I can test for Nutscrape and IE on my local and commercial web
host. The first part is all about testing for cookies enabled. The
second works out if to add the SID to the URL.
//////////////////////////////////////
/// Cookies //////////////////////////
///////////////////////////////////////
#---------------------------------------------------------------------
function COOKget($Varname){
# Try to get value from the cookies array
#---------------------------------------------------------------------
$rv='';
if (isset($_COOKIE[$Varname])){
$rv = $_COOKIE[$Varname];
}
return $rv;
}

#---------------------------------------------------------------------
function FlagCookies(){
# Decide if we can use cookies
# Set session var COOKIES 1=No 2=Yes
# COOKIES var is used by GoTo()
# This needs to be called twice on different page loads
# (1 to set cookie 2 to test)
# Eg once in login and once in main menu.
# Or could be done on any consecutive pages
# Or on single page ...
# ---------------------
# This returns TRUE if we are in the testing process and need to
# do another call. Use this if there is a home page without a
# definite sequence eg just a public main menu.
# if FlagCookies(){Goto(<thispageagain.php>);}
#---------------------------------------------------------------------
$rv = FALSE; // no need to do more testing
$progress = SESget(COOKIES);
if(!$progress){ // not started testing yet
setcookie('testcookie','arecookiesenabled',time() - 600);
SESset(COOKIES,-1); // testing - as yet unknown
$rv = TRUE; // more work to do
}else{
if($progress==-1){
$cook = COOKget('testcookie');
if(!$cook){
//print('no cookies');
SESset(COOKIES,1); // no
}else{
//print('cookies!');
SESset(COOKIES,2); // yes
}
}
}
return $rv;
}

#---------------------------------------------------------------------
function SESset($Varname,$Varval){
# Set session[{Varname}] to {Varval};
#---------------------------------------------------------------------
unset($_SESSION[$Varname]);
$_SESSION[$Varname] = $Varval;
}
#---------------------------------------------------------------------
function GoTo($NextPage,$Msg=''){
# This does a header(location...) to jump to another page
# The optional 2nd parameter attaches ?msg=... to the URL
# //NB If $NextPage is LASTRESORTBACKTO then take special action
# // - We might be in a flying page with no back and so we
# // want to close this window
#---------------------------------------------------------------------
if($NextPage==LASTRESORTBACKTO){
$NextPage='closer.htm';
}

if($Msg){
$message='?msg='.urlencode($Msg);
}else{
$message='';
}
/* header("Location: http://".$_SERVER['HTTP_HOST']
.dirname($_SERVER['PHP_SELF'])
."/".basename($NextPage).$message);
*/
if(SESget(COOKIES)==2){
$s='';
}else{
$s='?'.SID;
if($s=='?'){$s='';}
}
$h="Location: ".basename($NextPage).$s.$message;
header($h);
exit;
}


--
PETER FOX Not the same since the bottom fell out of the bucket business
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Jul 17 '05 #3

P: n/a
On Sat, 12 Mar 2005 09:49:55 +0000, Peter Fox
<pe******@eminent.demon.co.uk.not.this.bit.no.html > wrote:
vishal (vi************@yahoo.co.in) wrote:
: hi

: i am using session in php. but if the client has disabled his cookie
: then will my session work or not?????????


Try picking the bones out of the following. This seems to work OK as
far as I can test for Nutscrape and IE on my local and commercial web
host. The first part is all about testing for cookies enabled. The
second works out if to add the SID to the URL.


Hm - isn't this basically re-inventing session.use_trans_sid?

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #4

P: n/a
Andy Hassall wrote:
On Sat, 12 Mar 2005 09:49:55 +0000, Peter Fox
<pe******@eminent.demon.co.uk.not.this.bit.no.html > wrote:

<snip>
Try picking the bones out of the following. This seems to work OK asfar as I can test for Nutscrape and IE on my local and commercial webhost. The first part is all about testing for cookies enabled. The second works out if to add the SID to the URL.


Hm - isn't this basically re-inventing session.use_trans_sid?


Doesn't seem so--as he is just fiddling with the
header('Location:..')..

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #5

P: n/a
Following on from Andy Hassall's message. . .
Hm - isn't this basically re-inventing session.use_trans_sid?

Guilty m'lud.

But there was a good reason ...
.... lost in the mists of time.

Possibly I needed to know rather than just have it do it itself. Or
possibly the transparent addition was upsetting something else ... Don't
know.
--
PETER FOX Not the same since the cardboard box company folded
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.