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

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

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
5 3534
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
>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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ben | last post by:
Hi all, This has been asked in the past in different ways. I'm still a bit confused about setting up counters. I'm quite new to php. I've read few tutorials about writing counters using cookie and...
0
by: vishal | last post by:
hi today i read php5 and mysql book and i came to know that if cookie is enabled on client machine then php will use cookies to handle sessions else if cookie is disabled on client machine...
10
by: Tony Archer | last post by:
Gentlemen, your urgent help is needed in solving a STRANGE problem. I have two servers a dev box, and a production box. On the dev box everything works fine, in production it hoses: One of...
12
by: George Hester | last post by:
I have always used this in ASP to test if the client is accepting cookies: <%@language="VBScript"%> <% Session ("nc") = 1 If Len(Session("nc")) = 0 Then 'Cookies Off Else 'Cookies On End If
7
by: Christoph Pieper | last post by:
Hi, we've the following problem : We have an asp-application which sets the cookie on first login. The cookie will never be touched during user access. The user can work the whole day, but...
1
by: .NET Developer | last post by:
I'm having an issue that hopefully someone here can help me out with. First a quick explanation: I'm managing users of my site in a fairly custom way. (in other words I'm not using asp.net's...
0
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te...
3
by: Andrea | last post by:
I noticed that if cookie is disabled, unfortunately adding cookie to the collection doesn't trap any error, and this is really good for some aspects, because it's impossibile to understand that...
3
by: Jankie | last post by:
Hi I have disabled cookies in my browser just to test and discovered that session cookies are still set by php.I was looking for an example to set a session id cookie manually but couldnt find it.I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?

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.