Probleem met sid
big-smoke
05/02/2006 17:26:00Voor dit login systeem moet ik de sid toevoegen aan de url waarnaar ik naartoewil om ingelogd te blijven.Maar het lukt niet.Wat is er mis??
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?
/* starts a session with the name "sid", used to keep us logged in as long as there is a $sid variable in the url, which we are going to set up next */
session_name("sid");
session_start();
/* this is a simple function that adds the users sid to a url, it's based on the function that phpBB forums acctually use */
function add_sid($url){
/* sets some variables to current sessions name and id */
$s_name = session_name();
$s_id = session_id();
$sid = $s_name."=".$s_id;
if(!defined('LOGGED')){
/* regular url used if the user is not logged in */
return $url;
}else{
/* checks to see if the url already contains the session's variable */
if(preg_match("#$s_name=#", $url)){
/* if it does, return the url */
return $url;
}
/* this is used if the url doesn't have the proper variable, and the user is logged in
it formats the url using something similar to an if statement
visit http://php.net/manual/en/language.expressions.php for more info */
$url .= ((strpos($url, '?') !== false) ? '&' : '?') . $sid;
/* returns the properly formated url */
return $url;
}
}
?>
[/CODE]
/* starts a session with the name "sid", used to keep us logged in as long as there is a $sid variable in the url, which we are going to set up next */
session_name("sid");
session_start();
/* this is a simple function that adds the users sid to a url, it's based on the function that phpBB forums acctually use */
function add_sid($url){
/* sets some variables to current sessions name and id */
$s_name = session_name();
$s_id = session_id();
$sid = $s_name."=".$s_id;
if(!defined('LOGGED')){
/* regular url used if the user is not logged in */
return $url;
}else{
/* checks to see if the url already contains the session's variable */
if(preg_match("#$s_name=#", $url)){
/* if it does, return the url */
return $url;
}
/* this is used if the url doesn't have the proper variable, and the user is logged in
it formats the url using something similar to an if statement
visit http://php.net/manual/en/language.expressions.php for more info */
$url .= ((strpos($url, '?') !== false) ? '&' : '?') . $sid;
/* returns the properly formated url */
return $url;
}
}
?>
[/CODE]
Gewijzigd op 05/02/2006 17:49:00 door Big-smoke
Er zijn nog geen reacties op dit bericht.