PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > PHPSESSID in links
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
PHPSESSID in links

Réponse
 
LinkBack Outils de la discussion
Vieux 17/09/2007, 21h26   #1
Kevin Murphy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut PHPSESSID in links

I've got a site (password protected, sorry) where I have this in the
top of my template:

session_start();
$iSessionId = session_id();
$iSessionName = session_name();

Then I have a bunch of links like this in the site:

echo "<a href=\"/departments/\">Departments</a>";

The first time, and only the first time you load the page, that link
is transformed in the HTML output to be this:

<a href="/departments/?
PHPSESSID=4aec641b497131493b1c4bf489def723">Depart ments</a>

But if I reload the page, or go to any other page, I will get this:

<a href="/departments/">Departments</a>

which is what I want. Obviously I could do something where if it
detects the PHPSESSID in the URL, it forces the page to reload, but I
was thinking that there would be another way to do this without
adding another page load into the mix. Is there?

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada College
www.wnc.edu
775-445-3326

P.S. Please note that my e-mail and website address have changed from
wncc.edu to wnc.edu.
  Réponse avec citation
Vieux 17/09/2007, 21h41   #2
Stut
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] PHPSESSID in links

Kevin Murphy wrote:
> I've got a site (password protected, sorry) where I have this in the top
> of my template:
>
> session_start();
> $iSessionId = session_id();
> $iSessionName = session_name();
>
> Then I have a bunch of links like this in the site:
>
> echo "<a href=\"/departments/\">Departments</a>";
>
> The first time, and only the first time you load the page, that link is
> transformed in the HTML output to be this:
>
> <a
> href="/departments/?PHPSESSID=4aec641b497131493b1c4bf489def723">Depar tments</a>
>
>
> But if I reload the page, or go to any other page, I will get this:
>
> <a href="/departments/">Departments</a>
>
> which is what I want. Obviously I could do something where if it detects
> the PHPSESSID in the URL, it forces the page to reload, but I was
> thinking that there would be another way to do this without adding
> another page load into the mix. Is there?


These are caused by the php.ini setting session.use_trans_sid being on.
This setting allows sessions to work when are disabled.

http://php.net/ref.session#ini.session.use-trans-sid

I'm not sure why you have such a problem with it. Why is it important
that the URL does not contain the session ID?

Anyway, the way to "fix" it is to disable that php.ini setting.

-Stut

--
http://stut.net/
  Réponse avec citation
Vieux 18/09/2007, 15h24   #3
Anugrah Widya
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut dynamic <img>

dear friends ,

i have problem with dynamic image displaying

here the snippets

thumb.php
<?php
header("Content-type: image/jpg");
$file = "data/original/filename.jpg";
readfile($file);
?>

img.php
<img src="thumb.php?filename.jpg" />

problem is i always get broken images, someone know how to fix this ?

thx in advance
anuwidy
  Réponse avec citation
Vieux 18/09/2007, 15h41   #4
Daniel Brown
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut [PHP] dynamic <img>

Hello, Anugrah.

On 9/18/07, Anugrah Widya <anuwidy@gmail.com> wrote:
> i have problem with dynamic image displaying
>
> here the snippets
>
> thumb.php
> <?php
> header("Content-type: image/jpg");
> $file = "data/original/filename.jpg";
> readfile($file);
> ?>
>
> img.php
> <img src="thumb.php?filename.jpg" />


From your above examples, two questions come to mind:
1.) Is thumb.php in a folder above `data`? If not, adjust
your path accordingly.
2.) When using the query ?filename.jpg are you going to call
that as an $argv[1] variable? If you want to use it as a $_GET,
$_POST, or $_REQUEST, it will need a variable name with an assigned
value. For example:
<img src="thumb.php?img=filename.jpg">
L>thumb.php
<?
$path = "../data/original/"; // In case it's a same-level
directory as the PWD
$img = $_GET['img'];
header("Content-type: image/jpg");
readfile($path.$img);
?>

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Give a man a fish, he'll eat for a day. Then you'll find out he was
allergic and is hospitalized. See? No good deed goes unpunished....
  Réponse avec citation
Vieux 18/09/2007, 16h33   #5
Anugrah Widya
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] dynamic <img>

Daniel Brown wrote:
> Hello, Anugrah.
>
> On 9/18/07, Anugrah Widya <anuwidy@gmail.com> wrote:
>> i have problem with dynamic image displaying
>>
>> here the snippets
>>
>> thumb.php
>> <?php
>> header("Content-type: image/jpg");
>> $file = "data/original/filename.jpg";
>> readfile($file);
>> ?>
>>
>> img.php
>> <img src="thumb.php?filename.jpg" />

>
> From your above examples, two questions come to mind:
> 1.) Is thumb.php in a folder above `data`? If not, adjust
> your path accordingly.
> 2.) When using the query ?filename.jpg are you going to call
> that as an $argv[1] variable? If you want to use it as a $_GET,
> $_POST, or $_REQUEST, it will need a variable name with an assigned
> value. For example:
> <img src="thumb.php?img=filename.jpg">
> L>thumb.php
> <?
> $path = "../data/original/"; // In case it's a same-level
> directory as the PWD
> $img = $_GET['img'];
> header("Content-type: image/jpg");
> readfile($path.$img);
> ?>
>
> --
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
>
> Give a man a fish, he'll eat for a day. Then you'll find out he was
> allergic and is hospitalized. See? No good deed goes unpunished....


thank you Mr. Brown for your reply,

yep thumb.php and img.php are in the same level

correction for img.php
<img src="thumb.php?url=filename.jpg" />

i don't know what wrong with it, when i save the image data to another
files, the image didn;t corrupted, but when displayed dynamically it's
corrupted.., and the path are ok

did i miss something on this, and i didn;t aware of it ?
  Réponse avec citation
Vieux 18/09/2007, 16h40   #6
Stut
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] dynamic <img>

Anugrah Widya wrote:
> dear friends ,
>
> i have problem with dynamic image displaying
>
> here the snippets
>
> thumb.php
> <?php
> header("Content-type: image/jpg");
> $file = "data/original/filename.jpg";
> readfile($file);
> ?>
>
> img.php
> <img src="thumb.php?filename.jpg" />
>
> problem is i always get broken images, someone know how to fix this ?


Rather than viewing img.php, go directly to thumb.php?filename.jpg in
your browser. Change the content-type to text/plain and see what you get
in the browser.

You may also want to remove the ?> at the end of thumb.php - it's not
needed and may be adding whitespace to the image you are returning.

-Stut

--
http://stut.net/
  Réponse avec citation
Vieux 18/09/2007, 16h45   #7
Edward Kay
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] dynamic <img>


> >> thumb.php
> >> <?php
> >> header("Content-type: image/jpg");
> >> $file = "data/original/filename.jpg";
> >> readfile($file);
> >> ?>



Change
header("Content-type: image/jpg");
to
header("Content-type: image/jpeg");

Apparently IE doesn't like image/jpg [1].

[1] http://pear.php.net/bugs/bug.php?id=4586

Edward
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h32.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13151 seconds with 15 queries