session start

Started on the old forum in May 2010 · view the original in the archive · old links redirect here

29 replies · 1,757 views · started 16 years ago · 1 min read

6 participants
something else Fellow · 2,296 posts #21

Something like:

CREATE TABLE `sessions` (
  `Id` int(100) unsigned NOT NULL auto_increment,
  `user` varchar(50) default NULL,
  `sessionid` varchar(50) default NULL,
  PRIMARY KEY  (`Id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

If you are using $_SESSION there is no need for anything to be hard coded into your link so all you would need is main.php

(if you look at your bookmark on coding-talk it is there is no sid=4y89ryyry9ihuihiohjjjiy667y Coding-talk uses $_COOKIE which is similar to $_SESSION )

you only need a session id to be coded into your link if your not using $_SESSION ... if your not using $_SESSION the link could be what ever you wanted it to be eg: main.php?theCatSatOnTheMat=$theCatSatOnTheMat (providing you set a variable previously to $theCatSatOnTheMat )

wap_king Developer · 126 posts #22

yeah i get that but! i dont understand the session_id function how it works...or hw 2 code it...damn i need a programming book

something else Fellow · 2,296 posts #23

this was from other topic ... something like this ......

<?php
session_start(); 
include("x.php");

include("876con.php");

echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";

echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";

echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";

echo "<head>";

echo "<meta name=\"keywords\" content=\"chat,free,pics,photos,videos,myspace\"/>";

echo "<meta name=\"description\" content=\"Mobile community where you can meet people, chat, share pics and videos and play games on your cell phone.\"/>";

echo "<title>Chillblock | Meet People</title>";

echo "<link href=\"css/122538344.css\" rel=\"stylesheet\" type=\"text/css\" />";

echo "</head>";

echo "<body>";

if ($_GET['spy']=='1') 
{
$u = $_GET["u"];

$p = $_GET["p"];
}

echo "<p>";

$n = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE username='".$u."'"));

if($n[0]==0)

{

echo "<div class=\"error\">Username is Incorrect</div><a href=\"login.php\">Try Again</a><div class=\"copy\">Chillblock © 2010 All Rigths Reserved</div>";

$s = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE username='".$u."' AND password='".$p."'"));

}else{ 

if($s[0]==0)

{

echo "<div class=\"error\">Password is Incorrect</div><a href=\"login.php\">Try Again</a><div class=\"copy\">Chillblock © 2010 All Rigths Reserved</div>";

}else{

$sid = $u."hellothere".$p;

$ts = md5($sid);

$_SESSION['sid']=$ts; 

mysql_query("update users set ts ='$ts' where username='$u'");

echo "Welcome <b>$u</b><br/>";

echo "<a href=\"home.php?$x&$u\">Continue...</a><br/>";

}
}
echo "</p>";

echo "</body>";

echo "</html>";

?>

sorry iv just noticed your keeping session id on the table users .... so dont need a table called sessions lol

something else Fellow · 2,296 posts #24

so the code to check to see if your logged in will be something like:

$check = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE ts='".mysql_real_escape_string ($_SESSION['sid'])."'")); 

if($check[0]<1){ 
echo "u are nit logged in"; 
exit(); 
} 
wap_king Developer · 126 posts #25

oh thank you so much.....something else your the best ama test all that code now........one more thing do i have to use md5? cant i use something else i think md5 makes the session too long dnt like this sid=736fj873hfiud987amckhn i rather it to look like this sid=WWGH8....how can i get it like that?

something else Fellow · 2,296 posts #26

you wont even see session id using $_SESSION so it doesnt matter how long it is 🙂

wap_king Developer · 126 posts #27

$check = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE ts='".mysql_real_escape_string ($_SESSION['sid'])."'"));

if($check[0]<1){
echo "u are nit logged in";
exit();
}

when i use that all i get is a blank page

something else Fellow · 2,296 posts #28

try

$check = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE ts='".$_SESSION['sid']."'")); 
if($check[0]<1){ 
echo "u are nit logged in"; 
exit(); 
}

If it works it means you have magic_quotes_gpc turned on which automatically puts a backslash in front of every quote on all variable collection methods such as $_SESSION $_GET $_POST etc

wap_king Developer · 126 posts #29

something else wrote: try

$check = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE ts='".$_SESSION['sid']."'")); 
if($check[0]<1){ 
echo "u are nit logged in"; 
exit(); 

}

If it works it means you have magic_quotes_gpc turned on which automatically puts a backslash in front of every quote on all variable collection methods such as $_SESSION $_GET $_POST etc

still get blank page

something else Fellow · 2,296 posts #30

put this at top of page:

error_reporting  (E_ALL);
ini_set ('display_errors', true);

It will tell you whats wrong (delete it after you have solved problem)

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close