質問編集履歴

1

質問の内容が解らないので、再度コード編集。

2017/12/26 07:59

投稿

akobayashi
akobayashi

スコア15

test CHANGED
File without changes
test CHANGED
@@ -10,38 +10,52 @@
10
10
 
11
11
  ```ここに言語を入力
12
12
 
13
+ 修正コードでございます。
14
+
15
+ <?php
16
+
13
17
  if(isset($_COOKIE['user_title'])){
14
18
 
15
- $values[] = $value;
19
+ $values = array();
16
20
 
17
- $ligettime = 1800;
21
+ $value = $list['0']['Encode']['title'];
18
22
 
23
+ $values[] = $value;
24
+
25
+ $ligetime = 1800;
26
+
19
- foreach($values as $key => $tomato){
27
+ foreach($values as $key => $tomato){
20
28
 
21
29
  $key++;
22
30
 
23
- setcookie('user_title'.$namu,$tomato,time() + $ligetime, '/' );
31
+ setcookie('user_title'.$key,$tomato,time() + $ligetime, '/' );
24
32
 
25
33
  }
26
34
 
27
35
  }else{
28
36
 
29
- $values = array();
30
-
31
37
  $ligetime = 1800;
32
38
 
33
- $key = 0;
39
+ $value = $list['0']['Encode']['title'];
34
40
 
35
- $value = $list['0']['Encode']['title'];/*こちらはcakephp でページを見てエントリーをしたタイトルのデータです。
36
-
37
- setcookie('user_title'.$key,$value,time() + $ligetime, '/' );
41
+ setcookie('user_title',$value,time() + $ligetime, '/' );
38
42
 
39
43
  }
40
44
 
45
+
46
+
47
+
48
+
49
+ ?>
50
+
41
51
  ```
42
52
 
43
- 上記コードですとかならず上書きされてしまい
53
+ これでelseにまで処理がいくのです
44
54
 
45
- おそらく毎回elseの方込んでいんじゃないか思い、
55
+ クッキー見てみると
46
56
 
57
+ user_title
58
+
59
+ user_title1
60
+
47
- た改変しいる真っ最中でござい
61
+ で止っちゃってました