Jump to content

Loosing Session ID again :(


sorsha

Recommended Posts

While the user is logged in, i want it to keep my session id when I move from link to link. But its loosing it

When clicking on the link it first goes to this part of code

 

<?

session_name ('YourVisitID');

ini_set('session.use_cookies', 0); // Don't use cookies.

session_start();

$session = session_name('YourVisitID');

include ('./includes/header.html');

 

?>

 

<html> 

<meta http-equiv="refresh" 

content="0;url=showpage.php?page=1&YourVisitID=".SID.> 

</html>

 

Then that redirects to this code

 

<?

session_name ('YourVisitID');

ini_set('session.use_cookies', 0); // Don't use cookies.

$session = session_name('YourVisitID');

session_start();

 

include ('./includes/header.html');

?>

 

 

<html>

 

 

<center>

<h2>Becky's Photo Gallery</h2>

Please, click each thumbnail image to see more details. Thanks. 

<p>

 

<?php

 

 

#### Resizing Function #########

function imageResize($width, $height, $target) { 

if ($width > $height) { 

$percentage = ($target / $width); 

else { 

$percentage = ($target / $height); 

$width = round($width * $percentage); 

$height = round($height * $percentage); 

return "width=\"$width\" height=\"$height\""; 

#################################

echo ("<table border=1 cellpadding=5 cellspacing=5><tr>"); 

$page=$_GET['page']; 

 

  $mydir = dir('./data'); # read every file in the directory of "data"

  while(($file = $mydir->read()) !== false) {

  if (stristr($file, "JPG")){ # only JPG files

$total++; 

if ($total>28*($page-1) && $total<=28*($page)){

$count++; 

$mysize = getimagesize("./data/$file");

echo ("<td width=100 align=center valign=middle><a href=./view/show.php?id=$total>"); 

echo ("<img src=./data/$file "); 

echo (imageResize($mysize[0], $mysize[1], 100)); # thumbnail size 100 pixel

echo (" border=0></a></td>"); 

if ($count>6){

echo ("</tr><tr>"); 

$count=0; 

}

} #total<15

}

  }

 

# fill out the blank cells with *

 

if ($count>0){

for ($i=$count; $i<7; $i++){

echo ("<td align=center width=100>*</td>"); 

}

echo ("</tr>"); 

}

 

echo ("</table><p>"); 

 

# prepare the navigation menu for more images/pages

 

$n=((int)($total/29))+1; 

for ($i=1; $i<$n+1; $i++){

if ($i==$page){

echo ("<b>$i</b> "); 

}

else {

echo ("<a href=showpage.php?page=".$i."".SID.">".$i."</a> "); # page navigation; 28 images per page

}

}

 

?>

</center>

</html>

 

which on there should go to this code

 

<?php

session_name ('YourVisitID');

ini_set('session.use_cookies', 0);

session_start(); // Start the session.

 

?>

 

<html> 

<style type="text/css"> 

body { font-family: Georgia;         

background-color: #666666; } 

a { text-decoration: none; color: #FFFFFF; } 

a:hover { color: #888888; } 

</style> 

<center> 

<?php 

 

# this function is for resizing a given image, currently set with 600 pixel.

function imageResize($width, $height, $target) { 

if ($width > $height) {$percentage = ($target / $width); } 

else { $percentage = ($target / $height); } 

$width = round($width * $percentage); 

$height = round($height * $percentage); 

return "width=\"$width\" height=\"$height\""; 

 

# gather necessary information from the previous page with GET method 

$id=$_GET['id']; 

$interval=$_GET['interval']; 

$last=$_GET['last'];   

 

# if the slide show is on, show the next one, if nothing left, back to the first image

if ($interval){

echo ("<font size=2>Slid Show ON with $interval Seconds of Interval!</font><p>"); 

$forward=$id+1;

if ($forward>$_GET['last']){$forward=1;}

echo ('<META HTTP-EQUIV=Refresh CONTENT="'.$interval.'; 

URL=show.php?id='.$forward.'&interval='.$interval.'&last='.$last.'">'); 

 

# read every file from "data" directory (folder), and get only JPG files. case insensitive for "JPG"

$mydir = dir('../data');

while(($file = $mydir->read()) !== false) {

  if (stristr($file, "JPG")){

$count++; 

if ($id==$count){

$filename="../data/".$file;

$current=$id; 

}

}

  } 

# set the current image, and the previous and the next one by number (+/-)

$last=$count; 

$previous=$current-1; 

$next=$current+1; 

if ($current==1){$previous=$last;} # avoid the minus number

if ($current==$last){$next=1;} # avoid the out of range number 

# get the image size into an array 

$mysize = getimagesize("$filename"); 

echo ("<a href=show.php?id=".$previous.">Previous Image</a> | "); 

echo ("<a href=http://vanselow.soisuwm.com/final/index.php>HOME</a> | "); 

echo ("<a href=show.php?id=".$next."".SID.">Next Image</a>"); 

echo ("<p>"); 

echo ("<a href=$filename target=_blank ".SID."><img src=$filename "); 

if ($mysize[0]>600 && $mysize[1]>600){ # width AND height are greater than 600 pixel

echo (imageResize($mysize[0], $mysize[1], 600)); # resize upto 600 pixel

echo ("border=0></a>"); 

echo ("<p>");  ?> 

<form action=show.php> Change Slide Show Interval: 

<SELECT NAME="interval"> 

<OPTION value=5>5 seconds 

<OPTION value=10>10 seconds 

<OPTION value=15>15 seconds 

</SELECT>

<input type=hidden name=id value=<? echo $id; ?>> 

<input type=hidden name=last value=<? echo $last; ?>> 

<input type=submit value="GO!"> 

</form>

<p>

<font size=2 color=aqua>For the full screen display, press F11 key.</font> 

</center> 

</body> 

</html>

 

Yet its getting lost somewhere.

what am i doing wrong...  :shrug:

Help

Thanks !

 

Link to comment
https://forums.phpfreaks.com/topic/221582-loosing-session-id-again/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.