When user login my system I am holding its info on session.
Code:
$user = new User();
$user->setUyeid($row["UyeId"]);
$user->setAdsoyad($row["AdSoyad"]);
$user->setEmail($row["Email"]);
$user->setTelefon($row["Telefon"]);
$user->setOnay($row["Onay"]);
$user->setYetki($row["Yetki"]);
$user->setReferansid($row["ReferansId"]);
$user->setEngelbitistarihi($row["EngelBitisTarihi"]);
$user->setPremiumuyelikbitistarihi($row["PremiumUyelikBitisTarihi"]);
$user->setSmsabonelikbitistarihi($row["SmsAbonelikBitisTarihi"]);
$uye->setIp($IP);
$_SESSION["User"] = $user;
After login I try to access my session as a class but I couldn't do it.
$user = new User();
$user = $_SESSION["User"];
$user->test(); //IT IS NOT WORKING I HAVE ERROR
I can not do it. How can I solve this problem?
答案 0 :(得分:0)
您似乎没有使用session_start:
#include <stdio.h>
#include <stdlib.h>
int* functionOne(int size);
int main(void)
{
int size = 0;
if( scanf("%d",&size)!= 1){
fprintf(stderr,"Error in input\n");
exit(EXIT_FAILURE);
}
if( size <= 0){
fprintf(stderr,"Error in input [size]\n");
exit(EXIT_FAILURE);
}
int *arr = functionOne(size);
for(size_t i = 0; i < size; i++){
arr[i]=i;
}
for(size_t i = 0; i<size; i++){
printf("arr[%zu] = %d \n",i,arr[i]);
}
free(arr);
return 0;
}
int* functionOne(int size)
{
int *arr;
arr = malloc(sizeof(int)*size);
if( arr == NULL && size > 0){
perror("malloc");
exit(EXIT_FAILURE);
}
return arr;
}
登录后:
session_start();
$user = new User();
$user->setUyeid($row["UyeId"]);
$user->setAdsoyad($row["AdSoyad"]);
$user->setEmail($row["Email"]);
$user->setTelefon($row["Telefon"]);
$user->setOnay($row["Onay"]);
$user->setYetki($row["Yetki"]);
$user->setReferansid($row["ReferansId"]);
$user->setEngelbitistarihi($row["EngelBitisTarihi"]);
$user->setPremiumuyelikbitistarihi($row["PremiumUyelikBitisTarihi"]);
$user->setSmsabonelikbitistarihi($row["SmsAbonelikBitisTarihi"]);
$user->setIp($IP);
$_SESSION["User"] = $user;