LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-09-2005, 09:08 AM   #1
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
Why do I get a broken connection when I try to compare SID with a variable (PHP 4)


I have a little function where I am checking whether the SID constant has any value so that I can avoid the annoying little ? in the URL window. I want to append the SID when the cookies are disabled and I don't want to when cookies are enabled. This works fine without checking, except that the annoying little ? appears after the URL in the browser following by nothing.

Here's what I tried
PHP Code:
    function append_sid ($url)
    {
        
$sessionid strval(constant('SID'));
        if (
strlen($sessionid) != 0)
            
$sid_url $url '?' SID;
        else
            
$sid_url $url;
        return 
$sid_url;
    } 
However, the moment I try this, the connection refuses to work and the application seems to crash the connection.

What is the problem here?
 
Old 07-09-2005, 09:40 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,477

Rep: Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835
You don't need this hack, the function you want to accomplish
is supposed to be done by php internally.

What I don't get is the ? being added to your url, could you ellaborate ?
 
Old 07-09-2005, 10:00 AM   #3
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178

Original Poster
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
No it isn't. It depends on a special PHP.INI directive. If this directive is off, then it won't work.

I know, because before I used this function, the program works properly only with cookies enabled. If cookies aren't enabled then you need to pass the SID through the URL.

The point is, I want to check whether the SID constant is present or not. Because when cookies are enabled, then the constant is not present. This leads to an annoying ? in the URL followed by nothing.

Whenever I try to check this though, it works not.

I found that the actual problem here is nothing to do with what I originally thought but due to when I try to return something like this (nothing to do with the SID):
PHP Code:
function func ($var)
{
      
$new $var;
      return 
$new;

Then this breaks the web server connection. Any ideas?
 
Old 07-09-2005, 10:07 AM   #4
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178

Original Poster
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
I noticed that I am passing constants to the function above.

as defined by
PHP Code:
define ('CONSTANT''Value'); 
Could that be a reason as to why the above not only fails, but absolutely crashes the connection as well? Could it be a memory leak or something?
 
Old 07-09-2005, 11:34 AM   #5
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
The "book" recommends.

if(IsSet($session_id) ..

End
 
Old 07-09-2005, 11:35 AM   #6
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,477

Rep: Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835
For my part, I let the session.use_cookies = 1 in php.ini
if I disable coockie in the web browser client, the
session identifier (SID) is automatically added in the URL
so I don't see where the problem is.
 
Old 07-09-2005, 11:57 AM   #7
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178

Original Poster
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
As I said keefaz, in my local server the PHP.INI value

session.use_trans_sid

is set to off.

Maybe I'll just avoid the whole function and leave it as it is.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
anyone have broken ssh in etch/sid? m_yates Debian 7 04-02-2006 01:54 AM
php read from file and compare. xushi Programming 11 07-14-2005 02:10 PM
How do you compare variable in bash programming? chynna_v Programming 6 09-08-2004 03:17 AM
PHP Calculate, Compare.. Pts Gerardoj Programming 8 05-26-2004 01:54 AM
php date compare omarswan Programming 2 10-02-2002 05:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration